Microsoft XML 2.5 SDK


 

hasChildNodes Method

[This is preliminary documentation and subject to change.]

Returns true if this node has children.

Syntax

boolValue = oXMLDOMNode.hasChildNodes()

Returns

Boolean. Returns true if this node has children.

Remarks

This method offers a fast way to determine whether a node has children. This method always returns false for nodes that, by definition, cannot have children: the XMLDOMCDATASection, XMLDOMComment, XMLDOMNotation, XMLDOMProcessingInstruction, and XMLDOMText nodes.

Example

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("microsoft.xmldom")
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, XMLDOMCDATASection, XMLDOMCharacterData, XMLDOMComment, XMLDOMDocument, XMLDOMDocumentFragment, XMLDOMDocumentType, XMLDOMElement, XMLDOMEntity, XMLDOMEntityReference, XMLDOMNode, XMLDOMNotation, XMLDOMProcessingInstruction, XMLDOMText, XTLRuntime