Contains a node list containing the children (for nodes that can have children).
Syntax
objXMLDOMNodeList = oXMLDOMNode.childNodes
Remarks
Object. The property is read-only. Note that an XMLDOMNodeList object is returned even if there are no children of the node. In such a case, the length of the list will be set to zero. For information about valid child node types for each node, see the DOMNodeType enumeration.
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 XMLDOMNodeList 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 XMLDOMNodeList with a length of zero. These node types cannot have children. |
NODE_DOCUMENT_TYPE | Returns an XMLDOMNodeList that contains a list of all child nodes for the XMLDOMDocumentType node. The node list for the document type node can contain entities and notations. |
Example
The following example uses the childNodes property to create an XMLDOMNodeList object, then displays the number of child nodes in that object:
Dim xmlDoc
Dim root
Dim oNodeList
Set xmlDoc = CreateObject("microsoft.xmldom")
xmlDoc.async = False
xmlDoc.load("c:\books.xml")
Set root = xmldoc.documentElement
Set oNodeList = root.childNodes
MsgBox oNodeList.length
You can either use the item method to access individual nodes,
xmlDoc.documentElement.childNodes.item(1)
or you can directly access a child node by appending the desired index number in parentheses,
xmlDoc.documentElement.childNodes(1)
or with square brackets (except in VBScript):
xmlDoc.documentElement.childNodes[1]
Applies To
XMLDOMAttribute, XMLDOMCDATASection, XMLDOMCharacterData, XMLDOMComment, XMLDOMDocument, XMLDOMDocumentFragment, XMLDOMDocumentType, XMLDOMElement, XMLDOMEntity, XMLDOMEntityReference, XMLDOMNode, XMLDOMNotation, XMLDOMProcessingInstruction, XMLDOMText, XTLRuntime