preload

How to count XML nodes (QTP, VBScript)

Posted by Albert Gareev on Dec 29, 2009 | Categories: How toXML Data

Parent page: Service Functions – XML (QTP, VBScript) 

Answers


1. How to count all direct children?


Set objColl = objParent.ChildElements()
intCount = objColl.Count

2. How to count all direct children, specific name tag?


Set objColl = objParent.ChildElementsByPath("./wanted")
intCount = objColl.Count

3. How to count all descendants?


Set objColl = objParent.ChildElementsByPath("descendant::*")
intCount = objColl.Count

References

Read more about XPath queries.


Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported
This work by Albert Gareev is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported.