How to count the no of objects in XML file(QTP)



How to count the no of objects in XML file(QTP)..

Answer / uday kumar_anem

' To find the number of child elements for a specified
parent
Set doc = XMLUtil.CreateXML()
doc.LoadFile "e:\sample.xml"
Set elementCol = doc.ChildElementsByPath
("/Environment/Variable")
temp=elementCol.Count
msgbox(temp)

'To Find the numer of child elements for a root
Set doc=XMLUtil.CreateXML()
doc.loadfile "e:\sample.xml"
Set root = doc.GetRootElement()
temp=root.ChildElements().count
msgbox(temp)

My sample XML file is like:
<Environment>
<Variable>
<Name>Name</Name>
<Value>Uday Kumar</Value>
</Variable>
<Variable>
<Name>Designation</Name>
<Value>Senior Software Engineer</Value>
</Variable>
</Environment>

Is This Answer Correct ?    10 Yes 2 No

Post New Answer

More QTP Interview Questions

write a script for get the following result: username password frm the string1="A=username" string2="B=password"

3 Answers   Oracle,


in which situation u will use recording and in which situation u will used to write script manually

1 Answers  


Call to copy of an action and call to existing action… i know the diff but in real project how to use..? i want live scenario.pls help me..

0 Answers  


What are the differences between QTP 9.2 and 10? please explain e indetail......

2 Answers   Wipro,


What is the difference between QTP 8.2 and QTP 9.2

0 Answers   Nokia,


Up to how much VB scripting knowledge and what type of VB script knowledge is required for a QTP test engineer for real time to work ?

3 Answers  


Hi How to retrieve data from web element line by line?

0 Answers  


Can anyone tell me how i used QTP 9.2 use for GIS based S/w with an example?

0 Answers   IBM,


If 2 gmail browsers are opened in our system, how to enter the mail id and password into second browser by using discriptive program?

7 Answers   Mphasis,


supose i hv to acsess some functionlaties of a test in 1 machin , some part other machin how can acsess?

0 Answers   IBM,


Hi, Can anyone help me with: How to select a value from combobox and check the checkbox and set the filter. I have to set a filter by selecting a value from dropdown. Also, im using UFT 11.5 so can anyone help me with code for UFT. Thanks Sreevidya

1 Answers  


In an application you have a web table. You are provided with an external Excel sheet with the same structure as that of the web table. How will you retrieve all data from the web table and compare it with corresponding data available in the excel sheet, using QTP? How will you report the results in QTP?

1 Answers  


Categories