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

what is the difference between data driver & data driven and driver script?

0 Answers  


Describe how Smart Identification is used

0 Answers  


how can we write descriptive programming for menus when qtp is not able to identify it..and how can we write descriptive programming for partially identified and non standard objects..do i have to map the objects before writing the script

2 Answers  


I have recorded a test over web application(with IE6.0) in analog mode. But, while running it my test gets failed. Why? (Note: my systray has 3 open web applications)

7 Answers   Xansa,


I have a string "Redfort is in Delhi" how do u write vbscript for " Delhi in is Redfort"

4 Answers  






i want to handle all the unwanted pop up through QTP i done that with recovery scenario but it need some title of pop up but i want that it should handle all the pop up even i don't give the title of that pop up in recovery scenario is there any general way to handle all the pop up please help

3 Answers  


which type of testing process are you following in ur company? how to recognize a qtp page?

0 Answers  


In qtp, how you can exit for loop?

0 Answers  


How many types of Parameters are available in QTP?

1 Answers  


If you are testing a web application then what will you test in that application?

0 Answers   Infosys,


Can we write winrunner language i.e TSL in QTP tool?

0 Answers  


What r the features of QTP9.2,other than QTP8.0 What r the extre features of QTP9.2.

2 Answers  


Categories