I am trying to learn XPath, and finding it difficult, as I am Googling my way through it all.
Here is my XML:
<?xml version="1.0" encoding="utf-8"?>
<details>
<signature id="sig1">
<name>mr. Barry Smith</name>
<telephone type="fixed">01234 123456</telephone>
<telephone type="mobile">071234562</telephone>
</signature>
<signature id="sig2">
<name>mr. Harry Smith</name>
<telephone type="fixed">01234 123456</telephone>
</signature>
</details>
How can I find the names of people who have a mobile phone, I can get either or, but not both.
I have been trying things like this:
staffdetails/signature/telephone[@type='mobile']name
Also, is there a reference guide for using XPAth, so I can easily figure out any query I wish? Using online tutorials I have found explain how XPath works, but the examples don’t cover enough.
Thank you!
This should work:
It reads as:
Regarding the reference, I actually learnt the most from the examples in the spec!