Creating Documents  «Prev 

Creating a well-formed XML Document

  1. 1) A blank XML file
  2. Type the xml declaration line <?xml version="1.0" ?> and press Return. Note that there is no white space between the < and ? in the start element.
    2) Specify the XML version.
  3. Every XML document must have one and only one root element. The root element contains all other elements.
    Type the root element name of this XML document <inventory-items> and press Return.
    3)
    <inventory-items>
    
  4. This XML document describes inventory items. To begin the description of one such item, type <item> and press Return .
    4) item
    <item>
    
  5. We will use <item-name>, <item-serial-number>, and <units-on-hand> elements to describe one inventory item. Type <item-name>Computer Monitor</item-name> and press Return.
    5)
    <item-name>Computer Monitor</item-name>
    

  6. Type <item-serial-number>981</item-serial-number> and press Return.
    6) item-serial-number
    <item-serial-number>981</item-serial-number>
    
  7. Type <units-on-hand>50</units-on-hand> and press Return.
    We are now done with the description of this inventory item. Type </item> and press Return.
    7) Units on hand
    <units-on-hand>50</units-on-hand>
    
  8. Type the end element for the document root element </inventory-items> and press Return.
    8) Close the XML 'item' shown below.
    </item>
    
  9. You now have a well-formed XML document. Click Next to see what the document looks like when rendered in IE.
    9) Close the inventory items element in XML
    </inventory-items>
    
  10. This is what the XML document looks like when rendered in IE . This completes the Simulation. Click the Exit button.
    10) This is how the XML file looks when it is displayed in IE.
    <xml version="1.0"?>
    <inventory-items>
      <item>
        <item-name>Computer Monitor</item-name>
        <item-serial-number>981</item-serial-number>
        <units-on-hand>50</units-on-hand>
      </item>
    </inventory-items>