IXMLDOMNode object

The IXMLDOMNode object represents a node from an XML document. An IXMLDOMNode object can contain an IXMLDOMElement object, an IXMLDOMProcessingInstruction object, or an IXMLDOMText object.

Refer to IXMLDOMProcessingInstruction object, IXMLDOMElement object, or IXMLDOMText object for more information on how to use the following methods.

Creating a node

Use the createNode method from the DOMDocument object to create a new node. You must specify the node type with a constant from the IXMLNodeType enumeration, the name of the node, and the namespace for the node.

{Create an element as an IXMLDOMNode object.}
node = xmlDoc.createNode(MSXML.Node_Element, "Seller", "");

If you do not want to specify a namespace for the node, specify the empty string (""). Then node is created with the current document as the namespace.

Creating a node with the createNode method does not add the node to an XML document. You must add the node to an XML document with the insertBefore method, appendChild method, or the replaceChild method.

Adding a node

Use the insertBefore method to insert a nodes before another node in a document. You must specify the node you are adding as well as the node you are adding it in front of.

{Add the node before the nameElement.}
xmlDoc.insertBefore(node, nameElement);

You can also use the appendChild method to add a node after all of the other nodes in a document.

{Add the node to the XML document.}

Retrieving a node

The childNodes collection contains all of the nodes in an XML document. You can retrieve a node from the childNodes collection with the item method by the index associated with the node.

{Retrieve the first node from the childNodes collection.}
node = element.childNodes.item[0];

Replacing a node

Use the replaceChild method to replace a node in a document with another node. The node you are replacing is returned.

{Replace the element with a node.}
element = xmlDoc.replaceChild(element, node);

Retrieving the text content from a node

Use the text property to retrieve the text content from a node.

{Retrieve the text content from the node.}
nodeData = string(node.text);

Deleting a node

Use the removeNode method to remove a node from a document.

{Remove the node from the document.}

Documentation Feedback