OBJECT:  Document

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.

denotes a Microsoft extension to the W3C DOM.

PROPERTIES

async Property
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.

Syntax: Document.async = [true | false]

attributes Property
This is a read-only property that returns an NamedNodeMap for nodes that can have attributes.

Syntax: Node.attributes

baseName Property
This is a read-only property that returns the base name for a node.

Syntax: Node.baseName

childNodes Property
This is a read-only property containing a node list of all children for those elements that can have them.

Syntax: Node.childNodes

dataType Property
This is a read-only property that specifies the data type for the node.

Syntax: Node.dataType

definition Property
This property returns the definition of the node in the DTD or schema.

Syntax: Node.definition

doctype Property
This is a read-only property that contains the document type node that specifies the DTD for the document.

Syntax: Document.doctype

documentElement Property
This property contains the root element for the document.

Syntax: Document.documentElement

firstChild Property
This is a read-only property that returns the first child node of a node. If there is none, it returns null.

Syntax: Node.firstChild

implementation Property
This is a read-only property that contains the DOMImplementation object for the document. (A DOM application can use objects from multiple implementations.)

Syntax: Document.implementation

lastChild Property
This is a read-only property that returns the last child node of a node. If there is none, it returns null.

Syntax: Node.lastChild

namespaceURI Property
This property is read-only and returns the URI (Universal Resource Indentifier) of the namespace.

Syntax: Node.namespaceURI

nextSibling Property
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.nextSibling

nodeName Property
This property is read-only and contains the name of the node, depending on type.

Syntax: Node.nodeName

nodeType Property
This is a read-only property specifying the type of the node.

Syntax: Node.nodeType

nodeTypedValue Property
This property contains the value of this node expressed in its defined data type.

Syntax: Node.nodeTypedValue

nodeTypeString Property
This property is read-only and returns the node type in string form.

Syntax: Node.nodeTypeString

nodeValue Property
This property contains the value of the node, depending on type.

Syntax: Node.nodeValue

ondataavailable Property
This property is write-only, and specifies the event handler for the ondataavailable event.

Syntax: Document.ondataavailable

onreadystatechange Property
This property is write-only, and specifies the event handler for the onreadystatechange event.

Syntax: Document.onreadystatechange

ontransformnode Property
This property is write-only, and specifies the event handler for the ontransformnode event.

Syntax: Document.ontransformnode

ownerDocument Property
This property returns the Document object to which the node belongs. If the node itself is a document, then it returns null.

Syntax: Node.ownerDocument

parentNode Property
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.parentNode

parsed Property
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: Node.parsed

parseError Property
This property returns an XMLDOMParseError object containing information about the last parse error.

Syntax: Document.parseError

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: Node.prefix

preserveWhiteSpace Property
This property contains a boolean value of true if default processing preserves white space, or false otherwise.

Syntax: Document.preserveWhiteSpace

previousSibling Property
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 a child node (Attr, Document, DocumentFragment).

Syntax: Node.previousSibling

readyState Property
This property indicates the current state of the XML document.

Syntax: Document.readyState

resolveExternals Property
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: Document.resolveExternals

specified Property
This property returns a boolean value indicating whether this node (usually an attribute) is explicitly specified or derived from a default value in the DTD or schema.

Syntax: Node.specified

text Property
This property contains the text content of this node and its subtrees.

Syntax: Node.text

url Property
This property contains the canonicalized URL for the last loaded XML document.

Syntax: Document.url

validateOnParse Property
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: Document.validateOnParse

xml Property
This property contains the XML representation of this node and its descendants.

Syntax: Node.xml

METHODS

abort Method
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: Document.abort( )

appendChild Method
This method appends a new child node to the list of children for this node.

Syntax: Node.appendChild(tagName)

cloneNode Method
This method creates a clone node which is an exact replica of this node.

Syntax: Node.cloneNode(deep)

createAttribute Method
This method creates an Attr object of the specified name.

Syntax: Document.createAttribute(name)

createCDATASection Method
This method creates a CDATASection object whose value is the data supplied as the argument.

Syntax: Document.createCDATASection(data)

createComment Method
This method creates a Comment object whose value is the data supplied as the argument.

Syntax: Document.createComment(data)

createDocumentFragment Method
This method creates an empty DocumentFragment object.

Syntax: Document.createDocumentFragment( )

createElement Method
This method is used to create a new Element object of the type specified by the tagName argument.

Syntax: Document.createElement(tagName)

createEntityReference Method
This method creates a new EntityReference object of the specified name.

Syntax: Document.createEntityReference(name)

createNode Method
This method creates a node using the specified type, name and namespace.

Syntax: Document.createNode(type, name, nameSpaceURI)

createProcessingInstruction Method
This method creates a ProcessingInstruction object with the specified target name and data string.

Syntax: Document.createProcessingInstruction(target, data)

createTextNode Method
This method creates a new Text object whose value is the data passed as the parameter.

Syntax: Document.createTextNode(data)

getElementsByTagName Method
This method returns a NodeList collection of those elements with the tag name specified as the argument.

Syntax: Document.getElementsByTagName(tagName)

hasChildNodes Method
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.hasChildNodes( )

insertBefore Method
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: Node.insertBefore(newChild, refChild)

load Method
This method loads an XML document from the specified location

Syntax: Document.load(url)

loadXML Method
This method is used to load an XML document using the supplied string.

Syntax: Document.loadXML(xmlString)

nodeFromID Method
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.

Syntax: Document.noadFromID(idString)

removeChild Method
This method removes the specified node from the list of children and returns it.

Syntax: Node.removeChild(oldChild)

replaceChild Method
This method is used to replace one of a node's children with another. It returns the old child.

Syntax: Node.replaceChild(newChild, oldChild)

save Method
This method saves an XML document to a specified location.

Syntax: Document.save(objTarget)

selectNodes Method
This method creates a NodeList of all the matching descendant nodes returned by the specified pattern-matching operation.

Syntax: Node.selectNodes(patternString)

selectSingleNode Method
This method returns a Node object for the first descendant node to match the specified pattern.

Syntax: Node.selectSingleNode(patternString)

transformNode Method
This method processes this node and its descendants using the specified XSL stylesheet, and returns the resulting transformation.

Syntax: Node.transformNode(stylesheet)

transformNodeToObject Method
This method processes this node and its descendants using the specified XSL stylesheet, and returns the resulting transformation in the specified object.

Syntax: Node.transformNodeToObject(stylesheet, outputObject)

EVENTS

ondataavailable Event
This indicates that XML document data is available.

JScript Syntax: Document.ondataavailable="myHandlerFunction"

onreadystatechange Event
This indicates when the readyState property changes.

JScript Syntax: Document.onreadystatechange="myHandlerFunction"

ontransformnode Event
This is fired before each node in the XML source is transformed by each node in the stylesheet.

Syntax: boolean = ontransformnode(nodeCode, nodeData)


Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information