Building an XML Web Document Template

The information needed to create a complete XML document that will work in an XML-compliant browser such as Internet Explorer 5. We will begin in this chapter by building a well-formed XML document that will always default to standard HTML. Any browser can read this document. We will use XML Notepad to create an XML Web document using a simple user interface.

Using XML Notepad

XML Notepad enables us to focus on working with elements, attributes, and comments and to properly position them in the document structure. XML Notepad will handle the complexities of writing the XML document in a well-formed manner. In the section "The Final XML Document" later in this chapter, you'll find a review of the code created by XML Notepad. To create the initial document structure, follow these steps:

  1. To open XML Notepad, choose Program Files from the Start menu, and then choose Microsoft XML Notepad.
  2. XML Notepad will be displayed with a root element, which will contain all the other elements of the XML document. Every XML document must have a single root element to be well formed. Click on the root element (Root_Element), and rename it html.
  3. We will create two main child elements for our HTML document, body and head. Change the name of the default child element (Child_Element) to head.
  4. To add a second child element, click on head and choose Element from the Insert menu. Name the new child element body.
  5. Figure 3-1 shows XML Notepad after you've made these changes.

    Figure 3-1. XML Notepad, showing the root element and two child elements.

In this example, we will build a simple help desk Web page that uses a table to properly place the page elements in the Web browser. The Web page is shown in Figure 3-2.

Figure 3-2. Sample help desk Web page.

The table consists of two rows and two columns, for a total of four table cells, as shown in Figure 3-3. Notice that the title spans the two columns in the first row.

Figure 3-3. The four table cells.

In the following section, we'll create a generic template for producing Web pages that follow this design. These pages will use tables for formatting text and lists for presenting information.

by BrainBellupdated