Partager via


childNodes Property

 

Contains a node list containing the child nodes.

Script Syntax

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);  
   }  
}  

Visual Basic Syntax

objXMLDOMNodeList = oXMLDOMNode.childNodes  

C/C++ Syntax

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.

Remarks

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.

Versioning

Implemented in:

MSXML 3.0, MSXML 6.0

Applies to

IXMLDOMAttribute | IXMLDOMCDATASection | IXMLDOMCharacterData | IXMLDOMComment | IXMLDOMDocument-DOMDocument | IXMLDOMDocumentFragment | IXMLDOMDocumentType | IXMLDOMElement | IXMLDOMEntity | IXMLDOMEntityReference | IXMLDOMNode | IXMLDOMNotation | IXMLDOMProcessingInstruction | IXMLDOMText

See Also

IXMLDOMNodeList
nodeType Property1