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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
VulpesRank #55 · 29.2K reputationPosted Nov 7, 2014, 7:14 AM EST
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.
VulpesRank #55 · 29.2K reputationPosted Nov 7, 2014, 6:02 AM EST
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?
darma tejaRank #3,199 · 449 reputationPosted Nov 9, 2014, 10:06 PM EST