The Document object represents the entire XML document and is the primary means of access to it; it represents the top node of the DOM tree. Since none of the other nodes can exist outside of a document, it also contains all the factory methods necessary to create them. Once created, these child Node objects will each have an ownerDocument attribute associating them with the parent document.
Microsoft's implementation includes all of the base DOM document methods as well as additional methods and properties that support XSL and XML transformations. The document is the only object that can be created, all other objects and interfaces being accessed or created from within it.
There are two models of the Document: the free-threaded model and the rental threading model. They both behave exactly the same but differ in that the rental-treaded versions offer better performance because the parser doesn't need to manage concurrent access among threads.
Using JavaScript the two different models can be created in the following way:
var xml_doc = new ActiveXObject("Microsoft.XMLDOM");
var xml_ftdoc = new ActiveXObject("Microsoft.FreeThreadedXMLDOM");
And with VBScript:
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
Set objFTXMLDoc = new ActiveXObject("Microsoft.FreeThreadedXMLDOM")
Note:
Documents or nodes created by one method cannot be combined with those created by the other.
A Document is also a Node object, and so inherits various properties and methods from it. For details of the values returned by the nodeName, nodeType and nodeValue properties for a Document, see the Node object.
Syntax: document.async = [true | false]
This property determines whether asynchronous downloading of an XML file is permitted. The default is True, meaning that the load method returns control to the caller before the download is complete. false]
Syntax: node.attributes
This is a read-only property that returns a NamedNodeMap for nodes that can have attributes.
Syntax: document.basename
This is a read-only property that returns the base name for a node.
Syntax: node.childNodes
This is a read-only property containing a node list of all children for those elements that can have them.
Syntax: node.dataType
This is a read-only property that specifies the data type for the node.
Syntax: node.definition
This property returns the definition of the node in the DTD or schema.
Syntax: document.doctype
This is a read-only property that contains the document type node that specifies the DTD for the document.
Syntax: document.documentElement
This property contains the root element for the document.
Syntax: node.firstChild
This is a read-only property that returns the first child node of a node. If there is none, it returns null.
Syntax: document.implementation
This is a read-only property that contains the DOMImplementation object for the document. (A DOM application can use objects from multiple implementations.)
Syntax: node.lastChild
This is a read-only property that returns the last child node of a node. If there is none, it returns null.
Syntax: object.namespaceURI
This property is read-only and returns the URI (Universal Resource Indentifier) of the namespace.
Syntax: node.nextSibling
This property returns the next node in the parent's child list, or null if there is none or the node is of a type that cannot be a child node (Attr, Document, DocumentFragment).
Syntax: node.nodeName
This property is read-only and contains the name of the node, depending on type.
Syntax: node.nodeType
This property is read-only and contains the name of the node, depending on type.
Syntax: node.nodeTypedValue
This property contains the value of this node expressed in its defined data type.
Syntax: node.nodeTypeString
This property is read-only and returns the node type in string form.
Syntax: node.nodeValue
This property contains the value of the node, depending on type.
Syntax: object.ondataavailable
This property is write-only, and specifies the event handler for the ondataavailable event.
Syntax: object.onreadystatechange
This property is write-only, and specifies the event handler for the onreadystatechange event.
Syntax: object.ontransformnode
This property is write-only, and specifies the event handler for the ontransformnode event.
Syntax: node.ownerDocument
This property returns the Document object to which the node belongs. If the node itself is a document, then it returns null.
Syntax: node.parentNode
This is a read-only property that returns the parent node of all nodes except Document, DocumentFragment and Attr, which cannot have parent nodes.
Syntax: node.parsed
This property returns a boolean value of true if this node and all of its descendants have been parsed and instantiated. Otherwise it returns false.
Syntax: document.parseError
This property returns an XMLDOMParseError object containing information about the last parse error. prefix Property This property is read-only and returns the namespace prefix, or an empty string if none is specified. For example, it would return 'xxx' for the element xxx:yyy.
Syntax: object.prefix
Property This property is read-only and returns the namespace prefix, or an empty string if none is specified. For example, it would return 'xxx' for the element xxx:yyy.
Syntax: document.preserveWhiteSpace
This property contains a boolean value of true if default processing preserves white space, or false otherwise. By default it is false.
Syntax: node.previousSibling
This property returns the previous node in the parent's child list, or null if there is none or the node is of a type that cannot be an child node (Attr, Document, DocumentFragment).
Syntax: document.readyState
This property indicates the current state of the XML document.
Syntax: document.resolveExternals
This property returns a boolean value indicating whether external definitions (resolvable namespaces, DTD external subsets, and external entity references) are to be resolved at parse time, independent of validation.
Syntax: node.specified
This property returns a boolean value which indicates whether or not this attribute has a value specified in the XML document.
Syntax: node.text
This property contains the text content of this node and its subtrees.
Syntax: document.url
This property contains the canonicalized URL for the last loaded XML document.
Syntax: object.validateOnParse
This property contains a boolean value indicating whether this document should be validated by the parser. The default is true. If false, only well-formed XML will be parsed.
Syntax: node.xml
This property contains the XML representation of this node and its descendants.
Syntax: object.abort
This method aborts an asynchronous download in progress, discarding any portion of the XML tree already built. If the readyState property has a value of COMPLETED, no action is taken and the current document is unchanged.
Syntax: node.appendChild(tagName)
This method appends a new child node to the list of children for this node.
Syntax: node.cloneNode(deep)
This method creates a clone node which is an exact replica of this node.
Syntax: document.createAttribute(name)
This method creates an Attr object of the specified name.
Syntax: document.createCDATASection(data)
This method creates a CDATASection object whose value is the data supplied as the argument.
Syntax: document.createComment(data)
This method creates a Comment object whose value is the data supplied as the argument.
Syntax: document.createDocumentFragment( )
This method creates an empty DocumentFragment object.
Syntax: document.createElement(tagName)
This method is used to create a new Element object of the type specified by the tagName argument.
Syntax: document.createEntityReference(name)
This method creates a new EntityReference object of the specified name.
Syntax: document.createNode(type, name, nameSpaceURI)
This method creates a node using the specified type, name and namespace.
Syntax: document.createProcessingInstruction(target, data)
This method creates a ProcessingInstruction object with the specified target name and data string.
Syntax: document.createTextNode(data)
This method creates a new Text object whose value is the data passed as the parameter.
Syntax: document.getElementsByTagName(tagName)
This method returns a NodeList collection of those elements with the tag name specified as the argument.
Syntax: node.hasChildNodes
This method is a convenient way to determine whether a node has child nodes, returning true if it has, and false if not.
Syntax: node.insertBefore(newChild, refChild)
This method is used to insert a new child node before an existing one. If no child node exists, the new child node becomes the first.
Syntax: document.load(url)
This method loads an XML document from the specified location.
Syntax: object.load(url)
This method loads an XML document from the specified location
Syntax: document.loadXML(xmlString)
This method is used to load an XML document using the supplied string.
Syntax: object.nodeFromID
This method returns the node for the element whose ID attribute matches the one specified. If there is no match, it returns null. This method was designed to handle ID/IDREF relationships in XML, but does not require an attribute of type IDREF. It can be used generically, similarly to the all collection in DHTML. This method requires the use of a xml-schema or dtd.
Syntax: node.removeChild(oldChild)
This method removes the specified node from the list of children and returns it.
Syntax: node.replaceChild(newChild, oldChild)
This method is used to replace one of a node's children with another. It returns the old child.
Syntax: document.save(objTarget)
This method saves an XML document to a specified location.
Syntax: node.selectNodes(patternString)
This method creates a NodeList of all matching descendant nodes returned by the specified pattern-matching operation.
Syntax: node.selectSingleNode(patternString)
This method returns an object for the first descendant node to match the specified pattern.
Syntax: node.transformNode(stylesheet)
This method processes this node and its descendants using the specified XSL stylesheet, and returns the resulting transformation.
Syntax: node.transformNodeToObject(stylesheet, outputObject)
This method processes this node and its descendants using the specified XSL stylesheet, and returns the resulting transformation in the specified object.
Syntax: JScript Syntax: Document.ondataavailable="myHandlerFunction"
This indicates that XML document data is available.
Syntax: JScript Syntax: Document.onreadystatechange="myHandlerFunction"
This indicates when the readyState property changes.
Syntax: boolean = ontransformnode(nodeCode, nodeData)
This is fired before each node in the XML source is transformed by each node in the stylesheet.