Creating Documents  «Prev 

Creating a well-formed XML Document

  1. A blank XML file
    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.
    Specify the XML version
    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.
    Item Name and Serial Number
    3)
    <inventory-items>
    
  4. This XML document describes inventory items. To begin the description of one such item, type <item> and press Return .
    Computer Number
    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.
    Computer Monitor
    5)
    <item-name>Computer Monitor</item-name>
    

  6. Type <item-serial-number>981</item-serial-number> and press Return.
    Computer Monitor Serial Number
    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.
    Computer Monitor, Serial Number, units on hand
    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.
    Close the XML item
    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.
    Close the inventory items element in XML
    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.
    This is how the XML file looks when it is displayed in IE
    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>