Example:
<div class='known' name='unknown'>
How can I return name
attribute value ('unknown') based on known class
attribure value, with XPath 1.0?
While looking for an answer I found that XPath 2.0 has instrument for this:
//div[@class='known']/@name/string()
But can't find XPath 1.0 analogy
Use:
This produces the string value of the
name
attribute of the first in document orderdiv
element such that the string value of itsclass
attribute is"unknown"
.If
//div[@class='known']
selects more than onediv
element and you want the value of thename
attribute for the k-th selecteddiv
, use:where
$k
has to be substituted with the wanted integer, or otherwise the variable$k
must be in the evaluation context for the XPath expression.