QTP: Using XML files

I saw a question in the MIC forums today about how to get at specific data located in an XML file. The user was wondering how she could get at in a hierarchy. She was loading her file, but not as an XML file.

I gave her a good example, and here's the key: It's really pretty easy:

Dim oXML

Set oXML = CreateObject(”Microsoft.XMLDOM”)

oXML.Load sPathToXML

<Do stuff>

Set oXML = Nothing

And that's it to load an XML file. Really.

Once you have the XML document loaded, you can use all kinds of functions to get at the data and mainpulate it. Too many QTP script writers seem reluctant to fully accept this approach, instead relying on the tool (I am not a fan of the tool based solutions) to try and get at what they need.

Yes, it does require learning a new discipline, but it is completely worth it.

Here's a great reference on what you can do with the XMLDOM once you have the file loaded.

posted @ Friday, September 22, 2006 9:09 AM

Print

Comments on this entry:

# re: QTP: Using XML files

Left by Anfal at 4/11/2007 7:22 AM
Gravatar
its really good to know this point, could you please explain me the background process of QTP verifying a xml file content using a xml checkpoint.

Anfal

# re: QTP: Using XML files

Left by Anfal at 4/11/2007 7:22 AM
Gravatar
its really good to know this point, could you please explain me the background process of QTP verifying a xml file content using a xml checkpoint.

Anfal

# re: QTP: Using XML files

Left by Anfal at 4/11/2007 7:22 AM
Gravatar
its really good to know this point, could you please explain me the background process of QTP verifying a xml file content using a xml checkpoint.

Anfal

# re: QTP: Using XML files

Left by M Dora Babu - Banglore at 7/11/2007 2:47 AM
Gravatar
hi,

i want to know , how we can create a xml file of qtp object repository file objects.

# re: QTP: Using XML files

Left by Aruna at 3/11/2008 8:31 AM
Gravatar
using XMLUtil.createXML and loadfile I have loaded the XML file. Pls guide me how do I retrieve the attributes of the child? My code looks like this

Set objdoc=XMLUtil.CreateXML()
objdoc.loadFile = "C:\Test.xml"

set root = objdoc.GetRootElement()
set children = root.ChildElements()

set firstchild = children.item(1)
set secondchild = children.item(1).ChildElements()

For i = 1 to secondchild.count()
secondchild.item(i).ElementName()
Next

How will I get the attributes and the values of the secondchild.item(i).ElementName()

# re: QTP: Using XML files

Left by janani at 3/17/2008 12:40 AM
Gravatar
im not able to load a xml file please send me the guidelines how to load it

# re: QTP: Using XML files

Left by Reenu at 3/21/2008 6:18 PM
Gravatar
-----# re: QTP: Using XML files
left by Anfal at 4/11/2007 7:22 AM its really good to know this point, could you please explain me the background process of QTP verifying a xml file content using a xml checkpoint. ---
Hi Anfal....i am couple of years behind you but i now have the same queston. i am sure u have the answer by now. PLease share with me the answer
thanks
Reenu

# re: QTP: Using XML files

Left by Sonali at 5/9/2008 3:48 AM
Gravatar
I have created xml and imported.
With name title properties i was trying to identify the object. i found that explicilty i have to add the properties in the Object propeties dialog box and then only it was showing me the associated value for that property in the Object propeties dialog box.
And then i was able to highlight the object.

Can anyone tell me how to avoid this manual selecting of the object properties after importing the xml?
Is there any setting i have to do in Object Repository Manager?
Comments have been closed on this topic.
«December»
SunMonTueWedThuFriSat
30123456
78910111213
14151617181920
21222324252627
28293031123
45678910