The DOM implementation is just one of the MSXML core services. The following diagram shows the tasks involved in parsing an XML document and presenting the information to an application or script.
The DOM provides you with an interface for loading, accessing, manipulating, and serializing XML documents. The DOM provides a representation of a complete XML document stored in memory, providing random access to the contents of the entire document. The DOM allows applications to rely on the logic provided by the MSXML parser to handle XML-based information, using its facilities rather than writing custom code to read and process XML.
When the MSXML parser loads an XML document into a DOM, it reads it from start to finish and creates a logical model of nodes from the structures and content within the XML document. The document itself is considered a single node that contains all of the other nodes, including a node representing the root element, which, in turn, contains all of the element, attribute, and text nodes in the document.
Example
The following XML document has a simple multi-tier structure.
<?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="show_book.xsl"?> <!DOCTYPE catalog [ <!NOTATION XLS PUBLIC "http://www.microsoft.com/office/excel/"> <!ELEMENT COLLECTION (DATE? , BOOK+) > <!ATTLIST COLLECTION xmlns:dt CDATA #FIXED "urn:schemas-microsoft-com:datatypes"> <!ELEMENT BOOK (TITLE, AUTHOR, PUBLISHER) > <!ELEMENT DATE (#PCDATA) > <!ELEMENT TITLE (#PCDATA) > <!ELEMENT AUTHOR (#PCDATA) > <!ELEMENT PUBLISHER (#PCDATA) > ]> <!--catalog last updated 2000-11-01--> <catalog xmlns="http://www.example.com/catalog/"> <book id="bk101"> <author>Gambardella, Matthew</author> <title>XML Developer's Guide</title> <genre>Computer</genre> <price>44.95</price> <publish_date>2000-10-01</publish_date> <description><![CDATA[An in-depth look at creating applications with XML, using <, >,]]> and &.</description> </book> <book id="bk109"> <author>Kress, Peter</author> <title>Paradox Lost</title> <genre>Science Fiction</genre> <price>6.95</price> <publish_date>2000-11-02</publish_date> <description>After an inadvertant trip through a Heisenberg Uncertainty Device, James Salway discovers the problems of being quantum.</description> </book> </catalog>
After MSXML parsing, the top two levels of the node structure representing this document will look like this.
The topmost node is the document itself, which contains all of the other nodes. Immediately within the document are nodes representing the XML declaration, the style sheet processing instruction, the DOCTYPE declaration, and the root element for the document, in this case, catalog.
The catalog element contains the real content of the document, and its structure is shown below.
This part of the DOM contains element, attribute, text, and CDATA nodes. (The character references and built-in entities are converted to ordinary text by the parser, but the CDATA section has its own node.)
This part of the XML Document Object Model (DOM) reference describes the programming object syntax. The first table lists the core objects/interfaces. The second table lists the implemented objects/interfaces.
XML DOM Core Objects/Interfaces
The following objects/interfaces represent implementations of the XML DOM core objects/interfaces. The objects/interfaces include Microsoft extensions to support the following items and operations: namespaces, data types, XML schemas, Extensible Stylesheet Language (XSL), XSL Transformations (XSLT) operations, asynchronous loading, and the saving of documents.
Represents the top node of the XML DOM tree. | |
An extension of DOMDocument. This extension supports schema caching and runtime validation, and provides a way to switch on XML Path Language (XPath) support. | |
Enables iteration and access, by name, to the collection of attributes. IXMLDOMNamedNodeMapincludes support for namespaces. | |
Represents a single node in the document tree. IXMLDOMNode is the base interface for accessing data in the XML object model. This interface includes support for data types, namespaces, document type definitions (DTDs), and XML schemas. | |
Enables iteration and indexed access operations on the live collection of IXMLDOMNode. | |
Returns detailed information about the last error, including the error number, the line number, the character position, and a text description. | |
Provides client-side protocol support for communication with HTTP servers. |
XML DOM Implemented Objects/Interfaces
The following table represents implementations of other XML DOM interfaces.
Provides methods and properties that enable you to establish an HTTP connection between files or objects on different Web servers. This interface is derived from IXMLHTTPRequest. | |
Represents an attribute. | |
Quotes or escapes blocks of text so that text is not interpreted as markup language. | |
Provides text manipulation methods that are used by several objects. | |
Represents the content of an XML comment. | |
Represents a lightweight object that is useful for tree insertion operations. | |
Contains information associated with the document type declaration. | |
Represents the element. | |
Represents a parsed or unparsed entity in the XML document. | |
Represents an entity reference node. | |
Provides methods that are independent of any particular instance of the document object model. | |
Contains a notation declared in the DTD or schema. | |
Represents a processing instruction. XML defines this instruction to keep processor-specific information in the text of the document. | |
Represents a set of namespace URIs. | |
Represents a SchemaCache object. | |
An extension of IXMLDOMSchemaCollection. | |
Represents a list of nodes that match an XPath expression. | |
Represents the text content of an element or attribute. | |
Used for performing transformations with cached XSL templates. | |
Represents a cached XSL style sheet. |
For a list of all valid node types, see XML DOM Enumerated Constants.