XML

Interpreting the Content

You can also define the content in any manner you see fit. In our sample document, we added a CellContent element. You could have added numerous elements throughout the document to identify the content of each section. You could also have added attributes to existing elements. For example, you could have defined the ul element as follows:

  <ul type="" comment=""></ul>

These additional attributes and elements can then be used by an application to catalog the content of your documents. Imagine using these tags to build the search indexes for your Web site.

These extra tags and attributes also make the document much more readable to humans. When you are designing a Web site, you can define the content of different elements rather than just drawing what the page should look like. Certain components, such as the navigation bars at the top and sides of the page and the footer section, are likely to be shared by many pages. These components can be identified and can be added to the standard template. The developer will need to change only the elements on the page that differ from one page to the next.

Reusing Elements

In our sample template, you created elements that could be used to build a Web document. When it came time to add a new row, you copied the row structure and pasted a new row into the document. This new row had the entire structure already built into it. The same technique was used to duplicate several other elements, including the li element, the font element, the p element, and the a element.

Reusing elements that contain attributes and child elements guarantees that the entire document will be uniform. When you are building documents, this uniformity will help ensure that you are following the rules for the document. Reusable elements will also make it easier to build the entire document since you are building the document from predefined pieces. For example, it would be easy to include the additional h elements by reusing the p element. You would only need to insert the h2, h3, and h4 elements and copy and paste three p elements. In this example, you are reusing the p element. Figure 3-13 illustrates this.

Figure 3-13. XML Notepad, showing added h2, h3, and h4 elements.