Reputation: 12276
The XPath function string()
only returns the string value of the first node if it's fed a node list.
I'm using a selector that selects attributes:
//a/@href
This returns an array of href
nodes, which you have to map into each node's string values.
Is there a way to do this inside the selector?
E.G. something like //a/@href/string()
Upvotes: 1
Views: 913
Reputation: 111686
You must iterate the node set in the hosting language to convert each to its string value. string()
will indeed only take the string value of the first member of any nodeset passed to it.
Your requested XPath, //a/@href/string()
, would work directly.
Upvotes: 1