Click to return to the XML (Extensible Markup Language) home page    
XMLDOMNode firstChild Pro...     XMLDOMNode insertBefore M...     XMLDOMNode Object    
Web Workshop  |  XML (Extensible Markup Language)

hasChildNodes Method


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

[ Object Name ]
PlatformVersion
Win16:
Win32:
Mac:
Unix:
WinCE:
XMLDOMAttribute, XMLDOMCDATASection, XMLDOMCharacterData, XMLDOMComment, XMLDOMDocument, XMLDOMDocumentFragment, XMLDOMDocumentType, XMLDOMElement, XMLDOMEntity, XMLDOMEntityReference, XMLDOMNode, XMLDOMNotation, XMLDOMProcessingInstruction, XMLDOMText, XTLRuntime


Back to topBack to top

Did you find this topic useful? Suggestions for other topics? Write us!

© 1999 Microsoft Corporation. All rights reserved. Terms of use.