GetNodeList() |
Top Previous Next |
Example VBScript Code
Example VBScript Code
Private Sub DemoXML()
Dim oXML, ndRoot, ndChild, ndList Dim sBuff, sXML, i
'Create the object Set oXML = oUTILITIES.NewCommandoXMLObject()
'Using the With / End With statements make for easy shortcuts With oXML 'STEP 1 sBuff = "<EXAMPLE></EXAMPLE>" .OpenFromString sBuff Set ndRoot = .GetRootElement() .SetAttribute ndRoot, "DATE", oUTILITIES.VBFormat(Now, "dd mmm yyyy") 'Add Some Child Nodes sBuff = "<XCHILD></XCHILD>" For i = 1 To 5 Set ndChild = .XMLAddNode(ndRoot, sBuff) .SetAttribute ndChild, "INDEX", i Next sBuff = "<YCHILD></YCHILD>" For i = 1 To 3 Set ndChild = .XMLAddNode(ndRoot, sBuff) .SetAttribute ndChild, "INDEX", i Next Set ndList = .GetNodeList("XCHILD") If Not (ndList Is Nothing) Then sBuff = "The Document Contains " & ndList.Length & _ " XCHILD nodes" MsgBox sBuff, vbInformation, "GetNodeList()" End If Set ndList = .GetNodeList("YCHILD") If Not (ndList Is Nothing) Then sBuff = "The Document Contains " & ndList.Length & _ " YCHILD nodes" MsgBox sBuff, vbInformation, "GetNodeList()" End If 'Show the XML MsgBox .XML, vbInformation, "The CommandoXML Object" End With 'Clean up the objects Set ndRoot = Nothing Set ndChild = Nothing Set ndList = Nothing Set oXML = Nothing
End Sub
See Also: oUTILITIES.NewCommandoXMLObject() |