Dim o_XML
Dim s_XMLFilePath
s_XMLFilePath="E:\Programming Samples\QTP Samples\Cars.xml"
'Set o_XML=createobject("Microsoft.XMLDOM") 'DOM object of XML Parser.
' ' You can search the XML Parser ("Msxml.dll") in your system.
'o_XML.Async=false ' if it is false, then the file must be download first and the control goes back to the caller
' 'if it is true, then the control goes back to the caller before the file download
'o_XML.load(s_XMLFilePath) 'This method loads the XML File
'
'set o_ChildPath=o_XML.SelectNodes("/Cars/Make/Model/Name/text()")
'For i=0 to o_ChildPath.length-1
' print o_ChildPath(i).NodeValue
'Next
Set o_XML=XMLUtil.CreateXMLFromFile(s_XMLFilePath)
set o_ChildPath=o_XML.ChildElementsByPath("/Cars/Make/Model/Name")
For i=1 to o_ChildPath.Count
print o_ChildPath.Item(i).Value
Next
Set o_ChildPath=nothing
The content of the XML File as follows:
<Cars>
<Make name="Maruthi">
<Model>
<Name>Alto</Name>
<Release>2000</Release>
</Model>
</Make>
<Make name="Hundai">
<Model>
<Name>i10</Name>
<Release>2003</Release>
</Model>
</Make>
<Make name="Maruthi">
<Model>
<Name>Wagnor</Name>
<Release>2005</Release>
</Model>
</Make>
</Cars>
No comments:
Post a Comment