Returns True if this node has children.
boolValue = oXMLDOMNode.hasChildNodes()
Boolean. Returns True if this node has children.
This method offers a fast way to determine whether a node has children. It always returns False for nodes that, by definition, cannot have children: the XMLDOMCDATASection, XMLDOMComment, XMLDOMNotation, XMLDOMProcessingInstruction, and XMLDOMText nodes.
The following example checks a node to see if it has any child nodes. If it does, it displays the number of child nodes it contains:
Dim xmlDoc Dim currNode Set xmlDoc = CreateObject("Msxml2.DOMDocument") xmlDoc.async = False xmlDoc.load("c:\books.xml") Set currNode = xmlDoc.documentElement.firstChild If currNode.hasChildNodes Then MsgBox currNode.childNodes.length Else MsgBox ("no child nodes") End If
Applies To: XMLDOMAttribute Object | XMLDOMCDATASection Object | XMLDOMCharacterData Object | XMLDOMComment Object | DOMDocument Object | XMLDOMDocumentFragment Object | XMLDOMDocumentType Object | XMLDOMElement Object | XMLDOMEntity Object | XMLDOMEntityReference Object | XMLDOMNode Object | XMLDOMNotation Object | XMLDOMProcessingInstruction Object | XMLDOMText Object | XTLRuntime Object