The W3C DOM specifies a way of treating a document as a tree of nodes. In this model, every discrete data item is a node, and child elements or enclosed text become subnodes. Treating a document as a tree of nodes is one good way of handling XML documents (although there are others, as we'll see when we start working with Java) because it makes it relatively easy to explicitly state which elements contain which other elements; the contained elements become subnodes of the container nodes. Everything in a document becomes a node in this model—elements, element attributes, text, and so on. Here are the possible node types in the W3C DOM:
Element
Attribute
Text
CDATA section
Entity reference
Entity
Processing instruction
Comment
Document
Document type
Document fragment
Notation
For example, take a look at this document:
<?xml version="1.0" encoding="UTF-8"?> <DOCUMENT> <GREETING> Hello From XML </GREETING> <MESSAGE> Welcome to the wild and woolly world of XML. </MESSAGE> </DOCUMENT>
This document has a processing instruction node and a root element node corresponding to the <DOCUMENT> element. The <DOCUMENT> node has two sub-nodes, the <GREETING> and <MESSAGE> nodes. These nodes are child nodes of the <DOCUMENT> node and sibling nodes of each other. Both the <GREETING> and <MESSAGE> elements have one subnode—a text node that holds character data. We'll get used to handling documents like this one as a tree of nodes in this chapter. Figure 7.1 shows what this document looks like.
Every discrete data item is itself treated as a node. Using the methods defined in the W3C DOM, you can navigate along the various branches of a document's tree using methods such as nextChild to move to the nextChild node, or lastSibling to move to the last sibling node of the current node. Working with a document this way takes a little practice, and that's what this chapter is all about.
There are a number of different levels of DOM:
Level 0. There is no official DOM "level 0," but that's the way W3C refers to the DOM as implemented in relatively early versions of the popular browsers—in particular, Netscape Navigator 3.0 and Microsoft Internet Explorer 3.0.
Level 1. This level of the DOM is the current W3C recommendation, and it concentrates on the HTML and XML document models. You can find the documentation for this level at http://www.w3.org/TR/REC-DOM-Level-1/.
Level 2. Currently at the Candidate Recommendation stage, this level of the DOM is more advanced and includes a style sheet object model. It also adds functionality for manipulating the style information attached to a document. In addition, it enables you to traverse a document, has a built-in event model, and supports XML namespaces. You can find the documentation for this level at http://www.w3.org/TR/DOM-Level-2/.
Level 3. This level is still in the planning stage and will address document loading and saving, as well as content models (such as DTDs and schemas) with document validation support. In addition, it will also address document views and formatting, key events, and event groups. There is no documentation on this level yet.
Practically speaking, the only nearly complete implementation of the XML DOM today is that in Internet Explorer version 5 or later. You can find the documentation for the Microsoft DOM at http://msdn.microsoft.com/library/psdk/xmlsdk/xmld20ab.htm as of this writing. However, the Microsoft sites are continually (and annoyingly) being reorganized, so it's quite possible that by the time you read this, that page will be long gone. In that case, your best bet is to go to http://msdn.microsoft.com and search for "xml dom." (The general rule is not to trust an URL at a Microsoft site for more than about two months.)
Because Internet Explorer provides substantial support for the W3C DOM level 1, I'm going to use it in this chapter. Let's hope that the translation to other W3C-compliant browsers, as those browsers begin to support the W3C DOM, won't be terribly difficult.
Here are the official W3C DOM level 1 objects:
Object | Description |
---|---|
Document | The document object. |
DocumentFragment | Reference to a fragment of a document. |
DocumentType | Reference to the <!DOCTYPE> element. |
EntityReference | Reference to an entity. |
Element | An element. |
Attr | An attribute. |
ProcessingInstruction | A processing instruction. |
Comment | Content of an XML comment. |
Text | Text content of an element or attribute. |
CDATAsection | CDATA section |
Entity | Indication of a parsed or unparsed entity in the XML document. |
Notation | Holder for a notation. |
Node | A single node in the document tree. |
NodeList | A list of node objects. This allows iteration and indexed access operations. |
NamedNodeMap | Allows iteration and access by name to the collection of attributes. |
Microsoft uses different names for these objects and adds its own. In particular, Microsoft defines a set of "base objects" that form the foundation of its XML DOM. The top-level object is the DOMDocument object, and it's the only one that you create directly—you reach the other objects through that object. Here's the list of base objects in Internet Explorer. Note the objects designed to treat a document as a tree of nodes—XMLDOMNode, XMLDOMNodeList, and so on:
Object | Description |
---|---|
DOMDocument | The top node of the XML DOM tree. |
XMLDOMNode | A single node in the document tree. It includes support for data types, namespaces, DTDs, and XML schemas. |
XMLDOMNodeList | A list of node objects. It allows iteration and indexed access operations. |
XMLDOMNamedNodeMap | Allows iteration and access by name to the collection of attributes. |
XMLDOMParseError | Information about the most recent error. It includes error number, line number, character position, and a text description. |
XMLHttpRequest | Allows communication with HTTP servers. |
XTLRuntime | Supports methods that you can call from XSL style sheets. |
Besides these base objects, the Microsoft XML DOM also provides these XML DOM objects that you use when working with documents in code, including the various types of nodes, which you see supported with objects of types such as XMLDOMAttribute, XMLDOMCharacterData, and XMLDOMElement:
Object | Description |
---|---|
XMLDOMAttribute | Stands for an attribute object. |
XMLDOMCDATASection | Handles CDATA sections so that text is not interpreted as markup language. |
XMLDOMCharacterData | Provides methods used for text manipulation. |
XMLDOMComment | Gives the content of an XML comment. |
XMLDOMDocumentFragment | Is a lightweight object useful for tree insert operations. |
XMLDOMDocumentType | Holds information connected to the document type declaration. |
XMLDOMElement | Stands for the element object. |
XMLDOMEntity | Stands for a parsed or unparsed entity in the XML document. |
XMLDOMEntityReference | Stands for an entity reference node. |
XMLDOMImplementation | Supports general DOM methods. |
XMLDOMNotation | Holds a notation (as declared in the DTD or schema). |
XMLDOMProcessingInstruction | Is a processing instruction. |
XMLDOMText | Is text content of an element or attribute. |
We'll put many of these objects to work in this chapter, seeing how to parse and access XML documents using the Microsoft XML DOM and handling events as documents are loaded. We'll also see how to alter an XML document at run time.
This previous list of objects is pretty substantial, and each object can contain its own properties, methods, and events. Although most of these properties, methods, and events are specified in the W3C XML DOM, many are added by Microsoft as well (and so are nonstandard). If we're going to work with the XML DOM in practice, it's essential to have a good understanding of these objects, both practically for the purposes of this chapter and also for reference. I'll go through the major objects in some detail to make handling the XML DOM clear, starting with the main object, the DOMDocument object.
The DOMDocument object is the main object that you work with, and it represents the top node in every document tree. When working with the DOM, this is the only object that you create directly.
As we'll see in this chapter, there are two ways to create document objects in Internet Explorer: using the Microsoft.XMLDOM class and using XML data islands. Creating a document object with the Microsoft.XMLDOM class looks like this, where you explicitly load a document into the object with the load method:
function readXMLDocument() { var xmldoc xmldoc = new ActiveXObject("Microsoft.XMLDOM") xmldoc.load("meetings.xml") . . .
We'll also see that you can use the <XML> HTML element to create a data island in Internet Explorer, and then use the XMLDocument property of that element to gain access to the corresponding document object:
<XML ID="meetingsXML" SRC="meetings.xml"></XML> <SCRIPT LANGUAGE="JavaScript"> function readXMLDocument() { xmldoc = document.all("meetingsXML").XMLDocument . . .
XML DOM and Multithreaded ProgramsThere's also a "free-threaded" version of the Microsoft.XMLDOM class that you can use in multithreaded programs: var xmldoc = new ActiveXObject("Microsoft.FreeThreadedXMLDOM") For more information on this advanced topic, take a look at the Microsoft XML DOM site (at http://msdn.microsoft.com/library/psdk/xmlsdk/xmld20ab.htm as of this writing, but very probably moved by the time you read this). |
Here are the properties of this object:
Property | Description |
---|---|
async[*] | Indicates whether asynchronous download is allowed. Read/write. |
attributes | Holds the list of attributes for this node. Read-only. |
baseName[*] | Is the base name qualified with the namespace. Read-only. |
childNodes | Holds a node list containing child nodes for nodes that may have children. Read-only. |
dataType[*] | Gives the data type for this node. Read/write. |
definition[*] | Gives the definition of the node in the DTD or schema. Read-only. |
doctype | Specifies the document type node, which is what specifies the DTD for this document. Read-only. |
documentElement | Gives the root element of the document. Read/write. |
firstChild | Gives the first child of the current node. Read-only. |
implementation | Specifies the XMLDOMImplementation object for this document. Read-only. |
lastChild | Gives the last child node of the current node. Read-only. |
namespaceURI[*] | Gives the URI for the namespace. Read-only. |
nextSibling | Specifies the next sibling of the current node. Read-only. |
nodeName | Specifies the qualified name of the element, attribute, or entity reference. Holds a fixed string for other node types. Read-only. |
nodeType | Gives the XML DOM node type. Read-only. |
nodeTypedValue[*] | Holds this node's value. Read/write. |
nodeTypeString[*] | Gives the node type expressed as a string. Read-only. |
nodeValue | Is the text associated with the node. Read/write. |
ondataavailable[*] | Is the event handler for the ondataavailable event. Read/write. |
onreadystatechange[*] | Is the event handler that handles readyState property changes. Read/write. |
ontransformnode[*] | Is the event handler for the ontransformnode event. Read/write. |
ownerDocument | Gives the root of the document that contains this node. Read-only. |
parentNode | Specifies the parent node (for nodes that can have parents). Read-only. |
parsed[*] | Is true if this node and all descendants have been parsed; is false otherwise. Read-only. |
parseError[*] | Is an XMLDOMParseError object with information about the most recent parsing error. Read-only. |
prefix[*] | Gives the namespace prefix. Read-only. |
preserveWhiteSpace[*] | Is true if processing should preserve whitespace; is false otherwise. Read/write. |
previousSibling | Specifies the previous sibling of this node. Read-only. |
readyState[*] | Gives the current state of the XML document. Read-only. |
resolveExternals[*] | Indicates whether external definitions are to be resolved at parse time. Read/write. |
specified[*] | Indicates whether the node is explicitly given or derived from a default value. Read-only. |
text[*] | Gives the text content of the node and its subtrees. Read/write. |
url[*] | Specifies the canonical URL for the most recently loaded XML document. Read-only. |
validateOnParse[*] | Indicates whether the parser should validate this document. Read/write. |
xml[*] | Gives the XML representation of the node and all its descendants. Read-only. |
[*] Microsoft extension to the W3C DOM.
Here are the methods of the document object:
Method | Description |
---|---|
abort[*] | Aborts an asynchronous download |
appendChild | Appends a new child as the last child of the current node |
cloneNode | Returns a new node that is a copy of this node |
createAttribute | Returns a new attribute with the given name |
createCDATASection | Returns a CDATA section node that contains the given data |
createComment | Returns a comment node |
createDocumentFragment | Returns an empty DocumentFragment object |
createElement | Returns an element node using the given name |
createEntityReference | Returns a new EntityReference object |
createNode[*] | Returns a node using the given type, name, and namespace |
createProcessingInstruction | Returns a processing instruction node |
createTextNode | Returns a text node that contains the given data |
getElementsByTagName | Yields a collection of elements that have the given name |
hasChildNodes | Is true if this node has children |
insertBefore | Inserts a child node before the given node |
load[*] | Loads an XML document from the given location |
loadXML[*] | Loads an XML document using the given string |
nodeFromID[*] | Yields the node whose ID attribute matches the given value |
removeChild | Removes the given child node from the list of children |
replaceChild | Replaces the given child node with the given new child node |
save[*] | Saves an XML document to the given location |
selectNodes[*] | Applies the given pattern-matching operation to this node's context, returning a list of matching nodes |
selectSingleNode[*] | Applies the given pattern-matching operation to this node's context, returning the first matching node |
transformNode[*] | Transforms this node and its children using the given XSL style sheet |
transformNodeToObject[*] | Transforms this node and its children to an object, using the given XSL style sheet |
Here are the events of the document object:
Event | Description |
---|---|
ondataavailable[*] | Indicates that XML document data is available |
onreadystatechange[*] | Indicates when the readyState property changes |
ontransformnode[*] | Happens before each node in the style sheet is applied in the XML source |
The Microsoft XMLDOMNode object extends the core XML DOM node interface by adding support for data types, namespaces, DTDs, and schemas as implemented in Internet Explorer. We'll use this object a good deal as we traverse document trees. Here are the properties of this object:
Property | Description |
---|---|
attributes | The list of attributes for this node. Read-only. |
baseName[*] | The base name for the name qualified with the namespace. Read-only. |
childNodes | A node list containing the child nodes of the current node. Read-only. |
dataType[*] | The data type for this node. Read/write. |
definition[*] | The definition of the node in the DTD or schema. Read-only. |
firstChild | The first child of the current node. Read-only. |
lastChild | The last child of the current node. Read-only. |
namespaceURI[*] | The URI for the namespace. Read-only. |
nextSibling | The next sibling of this node. Read-only. |
nodeName | Holder for a qualified name for an element, attribute, or entity reference, or a string for other node types. Read-only. |
nodeType | The XML DOM node type. Read-only. |
nodeTypedValue[*] | The node's value. Read/write. |
nodeTypeString[*] | The node type in string form. Read-only. |
nodeValue | The text associated with the node. Read/write. |
ownerDocument | The root of the document. Read-only. |
parentNode | The parent node. Read-only. |
parsed[*] | True if this node and all descendants have been parsed; false otherwise. Read-only. |
prefix[*] | The namespace prefix. Read-only. |
previousSibling | The previous sibling of this node. Read- |
specified[*] | Indication of whether a node is explicitly given or derived from a default value. Read-only. |
text[*] | The text content of the node and its subtrees. Read/write. |
xml[*] | The XML representation of the node and all its descendants. Read-only. |
Here are the methods of this object:
Method | Description |
---|---|
appendChild | Appends a new child as the last child of this node |
cloneNode | Creates a new node that is a copy of this node |
hasChildNodes | Is true if this node has children |
insertBefore | Inserts a child node before the given node |
removeChild | Removes the given child node |
replaceChild | Replaces the given child node with the given new child node |
selectNodes[*] | Applies the given pattern-matching operation to this node's context, returning a list of matching nodes |
selectSingleNode[*] | Applies the given pattern-matching operation to this node's context, returning the first matching node |
transformNode[*] | Transforms this node and its children using the given XSL style sheet |
transformNodeToObject[*] | Transforms this node and its children using the given XSL style sheet, returning the result in an object |
You use the XMLDOMNodeList to handle lists of nodes. Node lists are useful because a node itself can have many child nodes. Using a node list, you can handle all the children of a node at once.
For example, here I'm loading a document and getting a list of all <PERSON> elements as a node list, using the document object's getElementsByTagName method:
function readXMLDocument() { var xmldoc, nodeList xmldoc = new ActiveXObject("Microsoft.XMLDOM") xmldoc.load("meetings.xml") nodeList = xmlDoc.getElementsByTagName("PERSON") . . .
The XMLDOMNodeList object has a single property, length, which describes the number of items in the collection and is read-only.
Here are the methods of the XMLDOMNodeList object:
Method | Description |
---|---|
item | Allows random access to nodes in the collection |
nextNode[*] | Indicates the next node in the collection |
reset[*] | Resets the list iterator |
The Microsoft XML DOM also supports an XMLDOMNamedNodeMap object, which provides support for namespaces. Here are the properties of this object:
Property | Description |
---|---|
length | Gives the number of items in the collection. Read-only. |
item | Allows random access to nodes in the collection. Read-only. |
Here are the methods of this object:
Method | Description |
---|---|
getNamedItem | Gets the attribute with the given name |
getQualifiedItem[*] | Gets the attribute with the given namespace and attribute name |
nextNode | Gets the next node |
removeNamedItem | Removes an attribute |
removeQualifiedItem | Removes the attribute with the given namespace and attribute name |
reset | Resets the list iterator |
setNamedItem | Adds the given node |
The Microsoft XMLDOMParseError object holds information about the most recent parse error, including the error number, line number, character position, and a text description. Although it's not obvious to anyone who loads an XML document into Internet Explorer, the browser does actually validate the document using either a DTD or schema if one is supplied. It's not obvious that this happens because, by default, Internet Explorer does not display any validation error messages. However, if you use the XMLDOMParseError object, you can get a full validation report, and I'll do so later in this chapter.
Here are the properties of this object:
Property | Description |
---|---|
errorCode | The error code of the most recent parse error. Read-only. |
filepos | The file position where the error occurred. Read-only. |
line | The line number that contains the error. Read-only. |
linepos | The character position in the line where the error happened. Read-only. |
reason | The reason for the error. Read-only. |
srcText | The full text of the line containing the error. Read-only. |
url | The URL of the XML document containing the last error. Read-only. |
Note that this object does not have any methods or events, and it does not correspond to any official W3C object in the W3C DOM.
In both the W3C and Microsoft DOM, attribute objects are node objects (that is, they are based on the node object), but they are not actually child nodes of an element and are not considered part of the document tree. Instead, attributes are considered properties of their associated elements. (This means that properties such as parentNode, previousSibling, or nextSibling are meaningless for attributes.) We'll see how to work with attributes in this chapter.
Here are the properties of the XMLDOMAttribute object:
Property | Description |
---|---|
attributes | The list of attributes for this node. Read-only. |
baseName[*] | The base name for the name qualified with the namespace. Read-only. |
childNodes | A node list containing child nodes. Read-only. |
dataType[*] | The data type of this node. Read/write. |
definition[*] | The definition of the node in the DTD or schema. Read-only. |
firstChild | The first child of the current node. Read-only. |
lastChild | The last child of the current node. Read-only. |
name | The attribute name. Read-only. |
namespaceURI[*] | The URI for the namespace. Read-only. |
nextSibling | The next sibling of this node. Read-only. |
nodeName | The qualified name for an element, attribute, or entity reference, or a string for other node types. Read-only. |
nodeType | The XML DOM node type. Read-only. |
nodeTypedValue[*] | The node's value. Read/write. |
nodeTypeString[*] | The node type in string form. Read-only. |
nodeValue | The text associated with the node. Read/write. |
ownerDocument | The root of the document. Read-only. |
parentNode | Holder for the parent node (for nodes that can have parents). Read-only. |
parsed[*] | True if this node and all descendants have been parsed; false otherwise. Read-only. |
prefix[*] | The namespace prefix. Read-only. |
previousSibling | The previous sibling of this node. Read-only. |
specified | Indication of whether the node (usually an attribute) is explicitly specified or derived from a default value. Read-only. |
text | The text content of the node and its subtrees. Read/write. |
value | The attribute's value. Read/write. |
xml | The XML representation of the node and all its descendants. Read-only. |
Here are the methods of the XMLDOMAttribute object:
Method | Description |
---|---|
appendChild | Appends a new child as the last child of this node |
cloneNode | Returns a new node that is a copy of this node |
hasChildNodes | Is true if this node has children |
insertBefore | Inserts a child node before the given node |
removeChild | Removes the given child node from the list |
replaceChild | Replaces the given child node with the given new child node |
selectNodes | Applies the given pattern-matching operation to this node's context, returning a list of matching nodes |
selectSingleNode | Applies the given pattern-matching operation to this node's context, returning the first matching node |
transformNode | Transforms this node and its children using the given XSL style sheet |
transformNodeToObject | Transforms this node and its children using the given XSL style sheet, and returns the result in an object |
This object does not support any events.
XMLDOMElement objects represent elements and are probably the most common node objects that you'll deal with. Because attributes are not considered child nodes of an element object, you use special methods to get the attributes of an element—for example, you can use the getAttribute method, which returns an XMLDOMNamedNodeMap object that contains all the element's attributes.
Here are the properties of the XMLDOMElement object:
Property | Description |
---|---|
attributes | The list of attributes for this node. Read-only. |
baseName[*] | The base name for the name qualified with the namespace. Read-only. |
childNodes | A node list containing the children. Read-only. |
dataType[*] | The data type for this node. Read/write. |
definition[*] | The definition of the node in the DTD or schema. |
firstChild | The first child of this node. Read-only. |
lastChild | The last child node of this node. Read-only. |
namespaceURI[*] | The URI for the namespace. Read-only. |
nextSibling | The next sibling of this node. Read-only. |
nodeName | Holder for the qualified name of an element, attribute, or entity reference, or a string for other node types. Read-only. |
nodeType | Indication of the XML DOM node type. Read-only. |
nodeTypeString[*] | The node type in string form. Read-only. |
nodeValue | The text associated with the node. Read/write. |
ownerDocument | The root of the document. Read-only. |
parentNode | The parent node of the current node. Read-only. |
parsed[*] | True if this node and all descendants have been parsed; false otherwise. Read-only. |
prefix[*] | The namespace prefix. Read-only. |
previousSibling | The previous sibling of this node. Read-only. |
specified[*] | Indication of whether the node is explicitly specified or derived from a default value in the DTD or schema. Read-only. |
tagName | Holder for the element name. Read-only. |
text[*] | Holder for the text content of the node and its subtrees. Read/write. |
xml[*] | Holder for the XML representation of the node and all its descendants. Read-only. |
Here are the methods of the XMLDOMElement object:
Method | Description |
---|---|
appendChild | Appends a new child as the last child of the current node |
cloneNode | Returns a new node that is a copy of this node |
getAttribute | Gets the value of the named attribute |
getAttributeNode | Gets the named attribute node |
getElementsByTagName | Returns a list of all descendant elements that match the given name |
hasChildNodes | Is true if this node has children |
insertBefore | Inserts a child node before the given node |
normalize | Normalizes all descendent elements, combining two or more text nodes next to each other into one text node |
removeAttribute | Removes or replaces the named attribute |
removeAttributeNode | Removes the given attribute from this element |
removeChild | Removes the given child node |
replaceChild | Replaces the given child node with the given new child node |
selectNodes[*] | Applies the given pattern-matching operation to this node's context, returning the list of matching nodes |
selectSingleNode[*] | Applies the given pattern-matching operation to this node's context, returning the first matching node |
setAttribute | Sets the value of a named attribute |
setAttributeNode | Adds or changes the given attribute node on this element |
transformNode[*] | Transforms this node and its children using the given XSL style sheet |
transformNodeToObject[*] | Transforms this node and its children using the given XSL style sheet, and returns the resulting transformation as an object |
The XMLDOMText object holds the text content of an element or attribute. If there is no markup inside an element, but there is text, that element will contain only one node—a text node that holds the text. (In mixed-content models, text nodes can have sibling element nodes.)
When a document is first made available to the XML DOM, all text is normalized, which means that there is only one text node for each block of text. You can actually create text nodes that are adjacent to each other, although they will not be saved as distinct the next time that the document is opened. (It's worth noting that the normalize method on the XMLDOMElement object merges adjacent text nodes into a single node.)
Here are the properties of the XMLDOMText object:
Property | Description |
---|---|
attributes | Holder for the list of attributes for this node. Read-only. |
baseName[*] | The base name for the name qualified with the namespace. Read-only. |
childNodes | A node list containing the child nodes. Read-only. |
data | This node's data (what's actually stored depends on the node type). Read/write. |
dataType[*] | The data type for this node. Read/write. |
definition[*] | The definition of the node in the DTD or schema. Read-only. |
firstChild | The first child of the current node. Read-only. |
lastChild | The last child of the current node. Read-only. |
length | The length, in characters, of the data. Read-only. |
namespaceURI[*] | The URI for the namespace. Read-only. |
nextSibling | The next sibling of this node. Read-only. |
nodeName | The qualified name of an element, attribute, or entity reference, or a string for other node types. Read-only. |
nodeType | Indication of the XML DOM node type. Read-only. |
nodeTypedValue[*] | This node's value. Read/write. |
nodeTypeString[*] | The node type in string form. Read-only. |
nodeValue | The text associated with the node. Read/write. |
ownerDocument | The root of the document. Read-only. |
parentNode | The parent node. Read-only. |
parsed[*] | True if this node and all descendants have been parsed; false otherwise. Read-only. |
prefix[*] | The namespace prefix. Read-only. |
previousSibling | The previous sibling of this node. Read-only. |
specified | Indication of whether the node is explicitly specified or derived from a default value. Read-only. |
text[*] | Holder for the text content of the node and its subtrees. Read/write. |
xml[*] | Holder for the XML representation of the node and all its descendants. Read-only. |
Here are the methods of the XMLDOMText object:
Method | Description |
---|---|
appendChild | Appends a new child as the last child of this node |
appendData | Appends the given string to the existing string data |
cloneNode | Returns a new node that is a copy of this node |
deleteData | Removes the given substring within the string data |
hasChildNodes | Is true if this node has children |
insertBefore | Inserts a child node before the specified node |
insertData | Inserts the supplied string at the specified offset |
removeChild | Removes the specified child node from the list of children |
replaceChild | Replaces the specified child node with the given new child node |
selectNodes[*] | Replaces the given number of characters with the given string |
selectSingleNode[*] | Applies the given pattern-matching operation to this node's context, returning a list of matching nodes |
specified[*] | Applies the specified pattern-matching operation to this node's context, returning an object |
splitText | Breaks this text node into two text nodes |
substringData | Returns a substring of the full string |
transformNode[*] | Transforms this node and its children using the given XSL style sheet |
transformNodeToObject[*] | Transforms this node and its children using the given XSL style sheet, and returns the resulting transformation as an object |
This object doesn't support any events.
That gives us an overview of the most commonly used objects in the Microsoft XML DOM. Now I'm going to put them to work in the rest of the chapter. I'll start at the beginning—loading an XML document.
3.128.197.164