CountChildNodes

Top  Previous  Next

Method

CountChildNodes(oNode, strNodeName)

Parameters

oNode (object, MSXML DOM Node), strNodeName (String, the name of the child node to count)

Returns

Numeric (Long) - The number of childnodes

Example

See Below.  CountChildNodes() returns the occurrence count of a node named <strNodeName> that is a child of <oNode>

 

 

Example VBScript Code

 

Private Sub DemoXML()

 

Dim oXML, ndRoot, ndList

Dim sBuff, i

 

'Create the object

Set oXML = oUTILITIES.NewCommandoXMLObject()

 

'Using the With / End With statements make for easy shortcuts

With oXML

   'Open an XML File

   If Not .OpenFromFile(oUTILITIES.ApplicationPath & "MyFileName.XML") Then

     SMEvent.Raise "ERROR", "XML File Open Failed"

   End If

    Set ndRoot = .GetRootElement()   

    i = .CountChildNodes(ndRoot, "OBR")

    MsgBox "This document has " & i & " OBR child nodes"

End With

'Clean up the objects

 

Set ndRoot = Nothing

Set oXML = Nothing

End Sub

 

See Also: oUTILITIES.NewCommandoXMLObject()