I have a node like this:
I want to be able to select this element i
Use:
//meta[@*[local-name() = 'description']]
This selects all meta
elements in the XML document that have an attribute with local-name "description"
.
By definition, the standard XPath function local-name() produces the name of the node from which the namespace prefix (if any) is stripped off.
Do note: Always avoid using the //
pseudo operator if the structure of the XML document is statically known. Often using //
causes slow execution.
Using XPath 2 you could do:
/meta[ends-with(@name, 'description')]
For XPath 1 we need:
/meta['description' = substring(@name, string-length(@name) - string-length('description') + 1)]