Wednesday, April 9, 2008

QTP XML Parser

How to parese XML imported from QTP repository?
Dim XMLNode, XMLFile
XMLFile = "C:\QTPObj.xml"
Set XMLNode = XMLUtil.CreateXMLFromFile(XMLFile).GetRootElement()
Function xmlParse(ByVal nodeName)
Dim Attrib, Node, firstChild, intX, intY
Set Attrib = nodeName.Attributes()
Set Node = nodeName.ChildElements ()
If nodeName.ElementName () = "qtpRep:Object" Then
If Attrib.Count = 2 Then
Print Attrib.Item(1).Value & "(" & Attrib.Item(2).Value &")."
End If
End If
'Get Childnode
For intX = 1 To Node.Count
Set firstChild = Node.Item(intX)
xmlParse firstChild
Next
End Function
'Parse the XML data
MatchData XMLNode

2 comments:

Abhi said...

Sunil, Goodwork, keep it up.......

simi said...

First of all. Thanks very much for your useful post.

I just came across your blog and wanted to drop you a note telling you how impressed I was with the information you have posted here.

Please let me introduce you some info related to this post and I hope that it is useful for software testing community.

There is a good Software Testing resource site, Have alook

http://SoftwareTestingNet.com

simi