   
hasChildNodes()
Is a member of:
|
DOMDocument
XMLDOMNode
XMLDOMAttribute
XMLDOMCDATASection
XMLDOMComment
XMLDOMDocumentFragment
XMLDOMDocumentType
XMLDOMElement
XMLDOMEntity
XMLDOMEntityReference
XMLDOMNotation
XMLDOMProcessingInstruction
XMLDOMText
XTLRuntime
|
blnValue = objXMLDOMNode.hasChildNodes()
This method is read-only. This method returns a boolean indicating whether the current Node has any children. It can be used instead of the length property, as explained earlier in this chapter.
We have snatched the following example from the length property and changed it to show how to use the
hasChildNodes() method.
In this example, we test the hasChildNodes() method to see if a DOMDocument has loaded properly. If the hasChildNodes() returned True, then we can proceed with the rest of the code working with the DOMDocument object.
Dim objDOMDocument As DOMDocument
Dim objNode As IXMLDOMNode
Set objDOMDocument = New DOMDocument
objDOMDocument.async = False
objDOMDocument.Load "http://localhost/xmlcode/people2.dtd"
If objDOMDocument.hasChildNodes Then
`run rest of code here
End If
Our code has loaded the XML from our main XML example. The hasChildNodes() method returns True; therefore, we can proceed with our
DOMDocument.    
This manuscript is an abridged version of a chapter
from the Manning
Publications book XML
Programming with VB and ASP. This chapter looks at the Microsoft DOM objects. NOTE: Most images have been removed to increase speed and many of the code comments have also been removed for presentation. Please purchase the book to enjoy the full experience of all the chapters with images and code comments!
|