XML Tutorials

  Home arrow XML Tutorials arrow Getting to Know XML
XML TUTORIALS

Getting to Know XML
By: James Payne
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 6
    2009-02-04

    Table of Contents:
  • Getting to Know XML
  • More Definitions
  • Determining the Form of Your Data
  • Different Types of XML

  •  
     

    SEARCH CODEWALKERS

    Getting to Know XML


    (Page 1 of 4 )

    In this second article in a series on beginning XML, I hope to familiarize you with some basic terminology used when discussing XML, as well as show you the basics of syntax, and furthermore, how to begin moving your data into an XML document.

    Just as a refresher, in our last article we talked about the advantages and disadvantages of XML, its history and lineage, and what XML is meant to do. For this article we will start with some definitions, so you can better understand the structure of the language. 

    What Does It Mean?  

    Attribute  

    An attribute in XML is a property that is associated with an element. It is also a named characteristic of an element and provides further information about an element. It is not, however, a part of an element's content. Here I will show you an example: 

    <car saleslot=”New York”> Mark’s Mazda Outlet </car> 

    Above, <car> and </car> are the elements. The word “saleslot” is an attribute that gives us more information about the <car> element. “New York” is a value ascribed to the “saleslot” attribute. The phrase “Mark’s Mazda Outlet” is the content that belongs to the <car> element. 

    Using “saleslot,” we now have more information about our <car> element; in this instance we can see that the location of Mark’s Mazda Outlet is in New York. While the visitor to your website might not see the saleslot=”New York” information, an example of its usage would come up if the user wanted to sort by location. You would have a program in place that looked for the value in the “saleslot” attribute and then sorted them accordingly. 

    Document Type Definition or DTD

    Every XML document must have rules to follow. This helps keep your data in order and protect its integrity. Document Type Definitions are one way to define those rules. Like XML, Document Type Definitions are based on SGML and dictate which elements or markup tags and attributes can be placed in your document. In addition, the DTD decides the order in which your elements and attributes can appear. You can also modify it to ensure that the elements and attributes appear in a strict order of your choosing. 

    I will provide more information about DTDs and something known as an XML Schema in a future article.

    Element  

    I described elements for you above, in the section on attributes. They are a part of your document that can be defined by starting and ending tags, with associated content in between. In the sample I will write below, we will take a look at several elements that might make up a database of information about a car seller. 

    <car> Mazda </car>

    <salesperson> Carl Fredericks </salesperson>

    <commissiontype> 1 </commissiontype>

    <salesdate> 10/22/2008 </salesdate> 

    Above we showcase four different elements. They are: car, salesperson, commissiontype, and salesdate. Each holds content that give us more information about the overall sale. In a later article we will discuss root, parent, and child architecture, and the role each of them has in a data structure such as the one above. For now, however, know that these are basic elements. 

    More XML Tutorials Articles
    More By James Payne

    blog comments powered by Disqus

    XML TUTORIALS ARTICLES

    - Validation with Document Type Definitions (D...
    - Creating a Well-Formed XML Document
    - Getting to Know XML
    - A Friendly Approach to XML
    - Creating RSS 2.0 Feeds
    - Using Modules in Your RSS Feed
    - RSS 2.0
    - Querying XML: Use Cases
    - Joins and Query Use with XML
    - Solving Problems by Querying XML
    - Performing Set Operations When Querying XML
    - Querying XML
    - Handling Data for Ajax with JSON
    - Handling XML Data for Ajax
    - XML and JSON for Ajax

    Developer Shed Affiliates

     



    © 2003-2019 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap