XMLUtil-4: How to get the NAME of the root element, get the COUNT of child elements of root, get COUNT & NAMES of children of any child element of root. Below code is showing COUNT & NAMES of children of 3rd child element of root. You can always change the code to suit your requirements.
XML file used:
Set doc = xmlutil.CreateXML
Set root = doc.GetRootElement
msgbox "Name of root element is: " & root.ElementName
Set children = root.ChildElements
msgbox "Root element has " & children.Count & " child elements."
q=cint (inputbox("Enter the no. of child element whose children you want to see "))
msgbox "No. of children of 3nd child of root are: " & children.Item(q).ChildElements.Count
For i= 1 to children.Item(q).ChildElements.Count
Result of running the above code:
And so on for ccc-3, ddd-3, eee-3.
How to find total number of child elements.
How to view ALL elements in a message box, one at a time.
How to view the VALUE of elements in a message box, one at a time.
How to create a new XML file.
How to move/transfer text from XML file to QTP DataTable.
How to compare two XML files.