Reputation: 439
<xyy:UP xmlns:xyy="urn:com" xmlns:xyx="urn:com" xmlns:xzx="urn:com">
<xyx:ITM>
<xzx:PID>ABCDEFGH</xzx:PID>
</xyx:ITM>
<xyx:ITM>
<xzx:PID>IJKLMNOP</xzx:PID>
</xyx:ITM>
</xyy:UP>
I tried follow xpath to get second 'PID' tag , which is having text node IJKLMNOP , but it wont return any.
//*[local-name()='PID'][1]
But it will list all the PID if I use follow
//*[local-name()='PID']
can any body drag me out of this plz
Upvotes: 2
Views: 2976
Reputation: 20748
//*[local-name()='PID'][1]
should return all 1st children PID elements, which are 2 in your sample document.
If you only want the 2nd one, you can use parentheses:
(//*[local-name()='PID'])[2]
(remember XPath positions start at 1, not 0)
Upvotes: 4