Working with the Document

MSXML 5.0 SDK

Microsoft XML Core Services (MSXML) 5.0 for Microsoft Office - DOM Developer's Guide

Working with the Document

The document map is represented by the DOMDocument object, which contains all of the information about the document. The DOMDocument object acts as the root node for all of the other nodes in the DOM tree. It contains the root element of the document, as well as information from before the root element—the prolog—and after the end of the root element.

The DOMDocument node can contain multiple IXMLDOMProcessingInstruction and IXMLDOMComment nodes, and one each of the IXMLDOMElement and IXMLDOMDocumentType nodes. These nodes are treated as children, and will appear in the same sequence in which they appeared in the original XML document.

Examples

To create a new document object, you must create a new instance of Msxml2.DOMDocument.

JScript

The following code is in Microsoft® JScript®.

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.5.0");

VBScript

The following code is in Microsoft Visual Basic® Scripting Edition (VBScript).

Set xmlDoc = CreateObject("Msxml2.DOMDocument.5.0")

After you create the DOMDocument object, you can set flags on it for different kinds of parsing and processing behavior, load XML documents, create new nodes inside the document to build an XML document from within your program, or persist your DOMDocument object as an XML file.

For more information about properties and methods of DOMDocument objects, see IXMLDOMDocument/DOMDocument.