You Are Here: Home >> Tech Notes >> XML Tutorial
Home
Consultants
Go Linux
Tech Notes
     B2B
     BizTalk
     XML Introduction
     XML Tutorial
     EDI & ECommerce
Links
Mailing Lists

Site Map

Contact Us
Linux mailing List

XML Brief Tutorial


Like HTML, XML uses element or tags:

   <tag>some data</tag>

As well as attributes:

   <tag attribute1="1" attribute2="value">some data</tag>

Thus, data can be represented:

  1. inside and opening and closing element, and
  2. as attributes inside an element, or
  3. as a combination of the two (as the examples above show)


XML Syntax

Although the words and structure used to form XML is very flexible, there are some rules for syntax that are more strict than HTML. Here is a brief list of XML rules:

  • XML documents must begin with a tag similar to: <?xml version="1.0"?>
  • XML elements all must have a corresponding closing tag:  <tag>some data</tag>
  • XML tags are Case Sensitive. Thus, the case of the opening and closing tags must match:
     <bookISBN>some data</bookISBN>
  • XML tags must be properly nested or else they will cause a "fatal error":
    wrong:  <a><b>some data</a></b>
    right:  <a><b>some data</b></a>
  • Each XML document must have a top level or root element. The root element must be an empty tag pair that contains all other elements in the document:
     <root>
       <a>
         <b>some data</b>
       </a>
     </root>
  • XML attribute values are required to be "quoted":
     <tag attribute1="1" attribute2="value">some data</b> </tag>
  • While HTML mostly ignores "whitespace" and "CR/LF" (carriage returns and line feeds), XML does not. Thus all spaces and line returns inside element tags are considered as valid data:
    <tag>some      space         between     data
         and
         CR/LF characters

    </tag>

Well Formed XML and Validation

XML is said to be Well Formed is it complies with the basic rules lists above. This means that the XML code follows the syntax rules and does not contain any syntax errors.

Valid XML means that the structure of the XML document conforms to a give structure design or schema. This is implemented either through Document Type Definition (DTD) or through XML Schemas.

  • DTDs define what elements are legal in a given XML document. DTD documents themselves use a different syntax and structure than XML. You can "include" the DTD document inside your XML document to link them. For an thorough tutorial on DTDs, check out W3C's DTD Tutorial.
  • XML Schemas are an XML-Based validation system and is an alternative to DTDs. XML Schemas can be argued as the successor to DTDs. W3C's XML Schema Tutorial may be of interest.


Advanced Topics

Other advanced XML and XML-related topics include:

  • Namespaces
  • Displaying (using CSS and XSL)
  • Embedding XML inside HTML
  • XML Encoding
  • XML Applications

Please reference the following links if you are interested in learning more about XML.

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
  For more information contact us at
1-888-451-3131
David Rutherford
druther@aei.on.ca
For More Information
Legal/Privacy
Statement
© 2003 Application Enhancements, Inc.
All rights reserved.