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.5.0"); var root; var oNodeList; var Item; xmlDoc.async = false; xmlDoc.load("books.xml"); if (xmlDoc.parseError.errorCode <> 0) { var myErr = xmlDoc.parseError; alert("You have error " + myErr.reason); } else { root = xmlDoc.documentElement; oNodeList = root.childNodes; for (var i=0; i<oNodeList.length; i++) { Item = oNodeList.item(i); alert(Item.xml); } }
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.DOMDocument50 Dim root As IXMLDOMElement Dim oNodeList As IXMLDOMNodeList Dim Item As IXMLDOMNode xmlDoc.async = False xmlDoc.Load ("books.xml") If (xmlDoc.parseError.errorCode <> 0) Then Dim myErr Set myErr = xmlDoc.parseError MsgBox("You have error " & myErr.reason) Else Set root = xmlDoc.documentElement Set oNodeList = root.childNodes For Each Item In oNodeList MsgBox Item.xml Next End If
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. |
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