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

Explain about Standard output value, Text output value, database o/p value, Xml O/p value, Xm o/p Value

1 Answers   TCS,


For QTP Test Engineer, What is his contribution to the Project? Means, As as automation test engineer what is his role in the current project?

0 Answers   V2 Solutions,


Write a script to delete a specific row in a webtable.

2 Answers   Tech Mahindra,


how can we do the frame work in qtp

0 Answers   L&T,


How many types of OBJECTS are there in QTP?

8 Answers   Intel, Inter Globe Technologies,






How do u retrieve data from a text file into different variables. i.e. in a text file named "source" , the data is like : india,1000,japan,200,china,50,singapore,45050 this is given in the first line of the text file. in the second line of the text file the dta is: sun,moon,planet,river,earth,water if u use "readline" method by using FSO concept u can retrieve the entire line in to a variable. but i want to import each field (ex: "india" in one variable, "1000" in another variable etc..). Apprecitae proper replies.

5 Answers   Semantic Space,


How to connect the remote desktop using QTP 9.2 explain the method or procedure?

0 Answers   Magna Infotech, Oracle,


How to add object to object repository in qtp9.0 Suppose for brower yahoo home page

0 Answers  


what is flag=0 in qtp tool.. i am strugglin to use flag function , exactly when it is used , any real time expert pls explain clearly?

1 Answers  


What is the basic concept of quicktest professional (qtp)?

0 Answers  


Explain features of the latest version of qtp/ uft 12.1?

0 Answers  


In QTP where i have to concentrate more in the Interview point of View

1 Answers  


Categories