I am trying to build an XPath select just the 'Phone' number from the following:
<element identifier="ContactPoint" version="Local">
<qualifier name="Phone" type="refining"/>
01234 567890
</element>
<element identifier="ContactPoint" version="Local">
<qualifier name="Email" type="refining"/>
[email protected]
</element>
In my XSLT, I have the following:
<TelNumber>
<xsl:value-of select="./element[@identifier='ContactPoint']"/>
</TelNumber>
But obviously this will just select the first instance. How would I combine conditions into one select to ensure I am only selecting the value of "element" with a "Phone" qualifier child?
Thanks!
The syntax for locating elements through XPath- Multiple Attribute can be written as: //<HTML tag>[@attribute_name1='attribute_value1'][@attribute_name2='attribute_value2]
Using OR & AND In the following XPath expression, it identifies the elements whose single or both conditions are true. Highlight both elements as the 'First Name' element having attribute 'id' and the 'Last Name' element having attribute 'name'. In the AND expression, two conditions are used.
If an xpath refers multiple elements on the DOM, It should be surrounded by brackets first () and then use numbering. if the xpath refers 4 elements in DOM and you need 3rd element then working xpath is (common xpath)[3].
The forward axis returns nodes in document order, the reverse axis returns nodes in reverse document order. A double colon :: is used to separate the axis specifier from the node test. Forward Axis. child. descendant.
.\element[@identifier='ContactPoint' and qualifier/@name='Phone']
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