CountChildNodes() |
Top Previous Next |
Object: EHL7.QSXML FileName: EHL7.dll
METHOD
Name: CountChildNodes() Parameters: 1) ndNode (Object of type "MSXML2.IXMLDOMNode") 2) strNodeName (String) Returns: Long Description: This method returns a count of all child nodes of an existing node that have the nodeName passed in strNodeName
Example: Dim myXMLObj As New EHL7.QSXML Dim strXML As String Dim ndRT As Object Dim ndChild As Object With myXmlObj .ClearErrors strXML = "<GOODXML></GOODXML>" Call .OpenFromString(strXML) If .IsError Then MsgBox .LastError .ClearErrors Exit Sub End If Set ndRT = .GetRootElement() 'ndRT is now an object of type MSXML2.IXMLDOMNode MsgBox ndRt.XML 'is the same as calling MsgBox myXMLObj.XML 'Add some child nodes strXML = "<CHILDNODE></CHILDNODE>" Call .XMLAddNode(ndRT,strXML) Call .XMLAddNode(ndRT,strXML) Call .XMLAddNode(ndRT,strXML) Call .XMLAddNode(ndRT,strXML) MsgBox Cstr(.CountChildNodes(ndRT,"CHILDNODE")) & " nodes" 'Now make some grandchildren Set ndChild = ndRT.ChildNodes(0) 'The first CHILDNODE strXML = "<GRANDCHILD></GRANDCHILD>" Call .XMLAddNode(ndChild,strXML) Call .XMLAddNode(ndChild,strXML)
Set ndChild = ndRT.ChildNodes(3) 'The last CHILDNODE strXML = "<GRANDCHILD></GRANDCHILD>" Call .XMLAddNode(ndChild,strXML) Call .XMLAddNode(ndChild,strXML) MsgBox Cstr(.CountChildNodes(ndChild,"GRANDCHILD")) & " grandchild nodes on CHILDNODE 4" End With Set myXMLObj = Nothing
|