Wednesday, December 2, 2009

Working With Microsoft XMLDOM using QTP

The following programme prints the values of XML file to QTP output window.

'CREATE THE COM OBJECT FOR XML USING Microsoft XMLDOM
Set xmlDOMObj = CreateObject("Microsoft.XMLDOM")

'Load XML file using
xmlDOMObj.Load("C:\plant_catalogue.xml")

'Assign PLAT nodes to a list nodes
Set nodes = xmlDOMObj.SelectNodes("/CATALOG/PLANT")
MsgBox "Total No. of Plants: " & nodes.Length

' GET ALL common NAMES of the plant
Set nodes = xmlDOMObj.SelectNodes("/CATALOG/PLANT/COMMON/text()")

' DISPLAY all the common name values
For i = 0 To (nodes.Length - 1)
NodeTitle = nodes(i).NodeValue
print "Plant Title #" & (i + 1) & ": " & NodeTitle
Next


download plant_catalog.xml from W3Schools

No comments:

Post a Comment