DOM
Expand Minimize

childNodes Property

Contains a node list containing the child nodes.

objXMLDOMNodeList = oXMLDOMNode.childNodes;

Example

The following script example uses the childNodes property (collection) to return an IXMLDOMNodeList, and then iterates through the collection, displaying the value of each item's xml property.

var xmlDoc = new ActiveXObject("Msxml2.DOMDocument.6.0");
var root;
var oNodeList;
var Item;
xmlDoc.async = false;
xmlDoc.load("books.xml");
if (xmlDoc.parseError.errorCode != 0) {
   var myErr = xmlDoc.parseError;
   WScript.Echo("You have error " + myErr.reason);
} else {
   root = xmlDoc.documentElement;
   oNodeList = root.childNodes;
   for (var i=0; i<oNodeList.length; i++) {
      Item = oNodeList.item(i);
      WScript.Echo(Item.xml);
   }
}

objXMLDOMNodeList = oXMLDOMNode.childNodes

HRESULT get_childNodes(
    IXMLDOMNodeList **childList);

Parameters

childList[out, retval]

A list of children in the current node.

C/C++ Return Values

S_OK

The value returned if successful.

E_INVALIDARG

The value returned if the childList parameter is Null.

The property (collection) is read-only. IXMLDOMNodeList is returned even if there are no children of the node. In such a case, the length of the list will be set to 0. For information about valid child node types for each node, see XML DOM Enumerated Constants.

This value depends on the value of the nodeType property.

NODE_ATTRIBUTE

NODE_DOCUMENT

NODE_DOCUMENT_FRAGMENT

NODE_ELEMENT

NODE_ENTITY

NODE_ENTITY_REFERENCE

Returns an IXMLDOMNodeList that contains a list of all child nodes for the specified node.

NODE_CDATA_SECTION

NODE_COMMENT

NODE_NOTATION

NODE_PROCESSING_INSTRUCTION

NODE_TEXT

Returns an IXMLDOMNodeList with a length of 0. These node types cannot have children.

NODE_DOCUMENT_TYPE

Returns an IXMLDOMNodeList that contains a list of all child nodes for the IXMLDOMDocumentType node. The node list for the document type node can contain entities and notations.

Implemented in:

MSXML 3.0, MSXML 6.0

Show:
© 2014 Microsoft