Slide 9.e: XML syntax
Slide 9.g: Business document exchange
Home

XML Syntax (Cont.)

  1. All XML elements must be properly nested.
    Improper nesting of tags makes no sense to XML. In HTML some elements can be improperly nested within each other like this:
      <b><i>This text is bold and italic</b></i>
    
  2. All XML documents must have a root element.

  3. All XML documents must contain a single tag pair to define a root element.

  4. All other elements must be within this root element.

  5. All elements can have sub elements (child elements).
    Sub elements must be correctly nested within their parent element.

  6. Attribute values must always be quoted.
    XML elements can have attributes in name/value pairs just like in HTML. In XML the attribute value must always be quoted.

  7. With XML, white space is preserved.
    With XML, the white space in your document is not truncated. This is unlike HTML. With HTML, a sentence like this:
      Hello              my name is Tove,
    
    will be displayed like this:
     Hello my name is Tove,
    
    because HTML strips off the white space.

  8. Comments in XML
    The syntax for writing comments in XML is similar to that of HTML.
      <!-- This is a comment -->
    

Demonstration