Quick References
      ADO
      ASP
      CSS2
      HTML
      JavaScript
      Jet SQL
      VBScript
      WML
      WMLScript
      WSH
      XHTML
      XML DOM
      XSLT

Features
      Knowledge Base
      Tutorials

Partners
     ZVON.ORG
     XML
     Planet Source Code
     VisualBuilder
     Web Design
     Your HTML Source
     XML/XSLT Forums
     ASPAlliance
     Scripts
     
     Programmers Heaven
     Tek-Tips Forums
     Developer Fusion
     Code Project











METHOD:  Object::hasChildNodes

Object  Attr   CDATASection   CharacterData   Comment   Document   DocumentFragment   DocumentType   Entity   EntityReference   Node   Notation   ProcessingInstruction   Text
 
Object.hasChildNodes( )

The hasChildNodes method is a convenient way to determine whether a node has child nodes, returning true if it has, and false if not.

In the following example we recursively drill down the DOM tree of the 'states.xml' file through the first child of each node. The nodeName is displayed at each level and the hasChildNodes method used to determine whether to recall the sub.

XML:
<States>
   <State ref="FL">
      <name>Florida</name>
      <capital>Tallahassee</capital>
   </State>
   <State ref="IA">
      <name>Iowa</name>
      <capital>Des Moines</capital>
   </State>
</States>

Code (VBScript):
Set objXMLDoc = CreateObject("Microsoft.XMLDOM")
objXMLDoc.async = False
objXMLDoc.load("states.xml")

Sub Drill(n)
   document.write(n.nodeName & "<br>")
   If n.hasChildNodes Then
      Set n = n.firstChild
      Drill(n)
   End If
End Sub

Drill(objXMLDoc.documentElement)

Output:
States
State
name
#text



 


Copyright 1999-2005 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information