IXMLDOMDocument interface properties and methods

In the above examples, we used the load method to get a reference to an actual XML document. The following tables list the properties, methods, and events associated with the IXMLDOMDocument interface. Properties and methods that are extensions of the W3C DOM Level 1 specification will be marked with an asterisk (*) throughout this chapter.

Code samples illustrating how to use the IXMLDOMDocument interface will be presented later in this chapter.

IXMLDOMDocument Properties

Name Description
async* Downloads the XML document asynchronously if this property is set to true (the default).
attributes Returns an XMLDOMNamedNodeMap object for nodes that can return attributes.
baseName* Returns the name of the node with any namespace removed.
childNodes Returns all children of the current node for nodes that are allowed children.
dataType* Sets or returns the data type for an XML document node that uses a schema. For entity references, elements, and attributes, if a data type is specified in the schema it will return the data type as a string. If no value is specified, it returns null, and for all other nodes it returns string. Attempts to set the dataType property for nodes other than attribute, element, or entity reference are ignored.
definition* Returns the node that contains the DTD or schema definition for the entity referenced.
doctype Returns a reference to an XMLDOMDocumentType node containing a reference to the DTD or schema.
documentElement Returns a reference to the outermost document element of an XML document.
firstChild Returns a reference to the first child of the current node.
implementation Returns a reference to the XMLDOMImplementation object for the document.
lastChild Returns a reference to the last child node of the current node.
namespaceURI* Returns the Uniform Resource Identifier (URI) for the namespace as a string.
nextSibling Returns a reference to the next sibling node of the current node.
nodeName Returns the name of the node.
nodeTypeString* Returns the node type as a string.
nodeType Returns the node type as a number.
nodeTypedValue* Returns or sets the strongly typed value of the node.
nodeValue Sets or returns the value of the node as text. Returns attribute value for attribute nodes. Returns the text within the CDATA section for CDATASection nodes. Returns the comment for comment nodes. Returns the processing instruction for processing instruction nodes. Returns the text for text nodes. For all other nodes, it returns null if you try to get the property and raises an error if you try to set the property.
ownerDocument Returns the root of the document that contains this node.
parentNode Returns the parent node of the current node for nodes that are allowed to have parents.
parsed* Returns true if the current node and all of its descendants have been parsed and instantiated.
parseError* Returns a reference to the XMLDOMParseError object that contains information about the last parsing error.
prefix* Returns the element namespace prefix as a string.
preserveWhiteSpace* Specifies if white space should be preserved. The default is false.
previousSibling Returns a reference to the previous sibling node of the current node.
readyState* Indicates the current state of an XML document.
resolveExternals* Resolves the external entities, and the document is resolved against external DTDs, if this is true. The default is false.
specified* Returns true if a node value is specified. Returns false if a node value is derived from a default value. (This is normally used only with attribute nodes.)
text* Sets and returns the text content of the current node and all of its descendants.
url* Returns the URL of the last successfully loaded XML document or returns null if the XML document was built in memory.
validateOnParse* The document will validate on parsing when this property is set to true, but the parser will only check the document for being well formed if this property is set to false. Default is true. This property can be set or read.
xml* Returns the entire XML content of the current node and all of its descendant nodes.

IXMLDOMDocument Methods

Name Description
abort()* Stops the asynchronous load if the async property is set to true and the document is loading. Any information that has been downloaded is discarded. If the readyState property is equal to COMPLETED, calling abort has no effect.
appendChild (newChild) Appends newChild to the end of the child nodes list for the currently selected node.
cloneNode (deep) Creates a clone node that is identical to the currently referenced node. If deep is set to true, all child nodes are also cloned.
createAttribute (name) Creates an attribute node with the specified name.
createCDATASection (text) Creates a CDATASection node containing text.
createComment (text) Creates a comment node containing text. The comment delimiters (<!-- -->) will be inserted.
createDocumentFragment() Creates an empty DocumentFragment node that is used to build independent sections of the XML document.
createElement (name) Creates an instance of the specified element.
createEntityReference (name) Creates an EntityReference node called name.
createNode (type, name, namespace)* Creates any type of node using the specified type, name, and namespace parameters.
createProcessingInstruction (target, data) Creates a new processing instruction. The target parameter provides both the target and the node name. The data parameter is the actual instruction.
createTextNode (text) Creates a text node containing the text specified in the text parameter.
getElementsByTagName (name) Returns a collection of child elements that have the specified tag name. If the name parameter is *, it returns all elements.
hasChildNodes() Returns true if the node has any child nodes.
insertBefore (newNode, beforeNode) Inserts a new node object called newNode into the list of child nodes for the current node to the left of the beforeNode or at the end if beforeNode is left out.
load (url)* Loads an XML document from the specified URL.
loadXML (string)* Loads a string that contains well-formed XML.
nodeFromID (value)* Returns the node object that has an ID attribute matching the supplied value.
removeChild (node) Removes the child node from the current node and returns it.
replaceChild (newNode, oldNode) Replaces the child node oldNode with the node newNode.
save (destination)* Saves the file to the specified destination.
selectNodes (pattern)* Returns a node list object containing matching nodes. The pattern parameter is a string containing an XSL pattern.
selectSingleNode (pattern)* Returns the first node object matching the pattern of a string containing XSL.
transformNode (stylesheet)* Processes the node and its children using XSL pattern matching. The stylesheet parameter must be either an XMLDOMDocument node object or a node object in the XSL namespace.
transformNodeToObject (stylesheet, outputobject) Transforms the node according to the XSL document and places the transformed document into the outputobject parameter.

IXMLDOMDocument Events

Name Description
ondataavailable* Occurs whenever data becomes available. When the async property is true, this event fires several times as data comes in. Using the readyState property, you can obtain information on the incoming data, including when all of the data has been downloaded.
onreadystatechange* Fires whenever the readyState property changes.
ontransformnode* Fires when a node is transformed using the TransformNode method of the node object.