Let us have a xml tree of depth N. I have traveresd the last node means i am at last note. Now i wanted to go back to some level up (say at N-3) in the xml tree from that last node.
Please let me know the syntax for the XPATH query so that i can reached at intended node in the xml tree.
Hey Hemant, we can use the double dot (“..”) to access the parent of any node using the XPath. For example – The locator //span[@id=”first”]/.. will return the parent of the span element matching id value as 'first.
XPath uses path expressions to select nodes or node-sets in an XML document.
Use:
ancestor::node()[3]
or
../../..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With