I have a simple requirement where in I need to fetch the value of attribute xml:id
i.e af1
.
I am making use of a SAXParser
and here is my xpath:a/aff/@xml:id
on the contrary I was able to fetch value of using the xpath:a/aff/@value
.
But i was unable to retrieve the value could you please help me?
<?xml version="1.0" encoding="UTF-8" ?>
<a>
<aff xml:id="af1" value="a">
<uAff>
Hello
</uAff>
</aff>
<aff xml:id="corr1">
<uAff>
Hello1
</uAff>
</aff>
</a>
Thanks in advance.
In xpath, there is contains () method. It supports partial matching with the value of the attributes. This method comes as useful while dealing with elements having dynamic values in their attributes. Using ^ to target attributes starting with a particular text.
Definition of XPath attribute. For finding an XPath node in an XML document, use the XPath Attribute expression location path. We can use XPath to generate attribute expressions to locate nodes in an XML document.
xsl". The XSL file uses the XPath expressions under select attribute of various XSL tags to fetchvalues of id, firstname, lastname, nickname andsalary of each employee node.
To get the value of the attributes you could use:
/a/aff/@*[name()='xml:id']
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