concept document in category .net

This is an excerpt from Manning's book IronPython in Action.
The main element in the MultiDoc user interface is the TabControl. It has TabPages, which map to the pages that the document holds.
Listing 5.4 is the read method of XmlDocumentReader. The element handlers passed into the constructor will be called when the reader encounters different elements in the document. This happens within the onStartElement method, which is called whenever an element start tag is encountered. Because you’re just handling elements, attributes, and contents, you need only three general node handlers: element start tags, element end tags, and the text contents of elements. Element attributes will be dealt with inside the element start tag node handler (listing 5.4).
The encoding declaration at the start is optional, but useful if the document is in an encoding other than ASCII or UTF-8. XML is a hierarchical format, so it must contain a root element, which contains the rest of the document. The root element can contain child elements, which themselves can contain child elements nested to whatever degree of horrific complexity you desire.
Back to the subject at hand: representing documents with XML. document will make an excellent root level element. You also need an element to represent pages. Each page has a title and contents. It seems logical that the title should be an attribute of the page start tag, and that the page contents should be the text content between the start and end elements. This will leave you with documents that look like the following segment:
<?xml version="1.0" encoding="utf-8"?>
<document>
<page title="The page title">This is the contents of the first page.</page>
<page title="Page Two">This is another page, as beautiful as the first.</
page>
</document>Now that the structure for representing documents is decided, you need to write the code to turn the model objects into XML.