XML

The Final XML Document

The final XML document is shown here:

  <?xml version="1.0" standalone="yes"?>
  <html>
      <head>
          <title>Northwind Traders Help Desk</title>
          <base target=""><!--Default link for page--></base>
      </head>
      <body text="#000000" bgcolor="#FFFFFF" link="#003399"
            alink="#FF9933" vlink="#996633">
          <!--Default display colors for entire body-->
          <a name="Top"><!--Anchor for top of page--></a>
          <table border="0" frame="" rules="" width="100%" align=""
                 cellspacing="0" cellpadding="0">
              <!--Rules/frame is used with border.-->
              <tr align="" valign="Center" bgcolor="">
                  <td rowspan="" colspan="2" align="Center" valign=""
                      bgcolor="">
                      <!--Either rowspan or colspan can be used,
                      but not both.-->
                      <!--Valign: top, bottom, middle-->
                      <CellContent cellname="Table Header">
                          <h1 align="Center">Help Desk</h1>
                      </CellContent>
                  </td>
              </tr>
              <tr align="" valign="Top" bgcolor="">
                  <td rowspan="" colspan="" align="Left" valign=""
                      bgcolor="">
                      <CellContent cellname="Help Topic List">
                          <p align="">
                          <ul type="">
                          <font face="" color="" size="3">
                              <b>For First-Time Visitors</b>
                          </font>
                          <li>
                          <a href="FirstTimeVisitorInfo.htm" target="">
                              First-Time Visitor Information
                          </a>
                          </li>
                          <li>
                          <a href="SecureShopping.htm" target="">
                              Secure Shopping at Northwind Traders
                          </a>
                          </li>
                          <li>
                          <a href="FreqAskedQ.htm" target="">
                              Frequently Asked Questions
                          </a>
                          </li>
                          <li>
                          <a href="NavWeb.htm" target="">
                              Navigating the Web
                          </a>
                          </li>
                          </ul>
                          </p>
                      </CellContent>
                  </td>
                  <td rowspan="" colspan="" align="Left" valign=""
                      bgcolor="">
                      <CellContent cellname="Shipping Links">
                          <p align="">
                          <ul type="">
                          <font face="" color="" size="">
                              <b>Shipping</b>
                          </font>
                          <li>
                          <a href="Rates.htm" target="">
                              Rates
                          </a>
                          </li>
                          <li>
                          <a href="OrderCheck.htm" target="">
                              Checking on Your Order
                          </a>
                          </li>
                          <li>
                          <a href="Returns.htm" target="">
                              Returns
                          </a>
                          </li>
                          </ul>
                          </p>
                      </CellContent>
                  </td>
              </tr>
          </table>
      </body>
  </html>

The final document looks basically like an HTML document and works like one, but it meets the criteria for being a well-formed XML document. Notice that all of the tags nest properly, all tags are closed, and the root element (<html></html>) encloses all the other elements.

You could have written all of this XML code manually, but it would have been more difficult and you would have been more likely to make a syntax error. There are various XML editors such as XML Authority, XML Instances, and XML Spy that allow you to focus on the structure of your document and the elements that will go into your document without being concerned about the syntax. Of course, once you have finished with the XML editor, you should review the final document to verify that the XML code is actually what you want.

Summary

Well-formed XML documents can be created by using elements, attributes, and comments. These components define content within the document. Using these definitions, applications can be created that will manipulate the content.

The requirements for well-formed documents that have been addressed in this chapter include having a single root element, having properly nested elements, having no duplicate attribute names in an element, and enclosing all attribute values in single and double quotation marks. Using XML editors to create XML documents will allow you to focus on defining the structure of your document, the first step in building a well-formed XML document.

To make a class of documents with the same format as the one we created in this chapter, you will want to create a DTD to validate the entire class of documents. In the next chapter, you will learn how to create DTDs, and you will create one specifically for this document.