childNodes Property
Contains a node list containing the children nodes.
[Script]
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.4.0");
var root;
var oNodeList;
var Item;
xmlDoc.async = false;
xmlDoc.load("books.xml");
root = xmlDoc.documentElement;
oNodeList = root.childNodes;
for (var i=0; i<oNodeList.length; i++) {
Item = oNodeList.item(i);
alert(Item.xml);
}
[Visual Basic]
Visual Basic Syntax
objXMLDOMNodeList = oXMLDOMNode.childNodes
Example
The following Microsoft® Visual Basic® 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.
Dim xmlDoc As New Msxml2.DOMDocument40
Dim root As IXMLDOMElement
Dim oNodeList As IXMLDOMNodeList
Dim Item As IXMLDOMNode
xmlDoc.async = False
xmlDoc.Load ("books.xml")
Set root = xmlDoc.documentElement
Set oNodeList = root.childNodes
For Each Item In oNodeList
MsgBox Item.xml
Next
[C/C++]
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 childList 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. |
To view reference information for Visual Basic, C/C++, or Script only, click the Language Filter button
in the upper-left corner of the page.
See Also
IXMLDOMNodeList | nodeType Property
Applies to: IXMLDOMAttribute | IXMLDOMCDATASection | IXMLDOMCharacterData | IXMLDOMComment | DOMDocument | IXMLDOMDocumentFragment | IXMLDOMDocumentType | IXMLDOMElement | IXMLDOMEntity | IXMLDOMEntityReference | IXMLDOMNode | IXMLDOMNotation | IXMLDOMProcessingInstruction | IXMLDOMText