How can I get xpath from a specific nodename?
I would like to know that Xpath of "final" node. the output like this: root/test/
Thanks,
Darma
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted Nov 7, 2014, 12:14 PM
http://stackoverflow.com/questions/241238/how-to-get-xpath-from-an-xmlnode-instance-c-sharp
I slotted in your XML sample and it gave:
/root[1]/test[1]/final[1]
so, apart from the redundant indices in this example, it seems to be working OK.
darma tejaPosted Nov 10, 2014, 3:06 AM
VulpesPosted Nov 7, 2014, 11:02 AM
However, the problem is that, in the general case, there might be multiple nodes called 'final' and so the XPath wouldn't be unique.
Is that a problem for you or will it suffice to just get the XPath of the first matching node found?