I have XML that looks like this:
<node1>
<item>hello</item>
<item>world</item>
</node1>
I would like this to output the following using an XPath expression:
hello, world
Is this possible with XPath 1.0? I have been looking around but unable to find anything.
Thanks, Cinegod
XPath 2.0 can do string-join(/node1/item, ', ')
. With XPath 1.0 you can't do that, you would need to use a host language like XSLT or a procedural language exposing an XPath API to iterate over nodes and concatenate values.
In XPath 1.0 you can do that by using concat()
, e.g.:
concat(node1/item[1], ", ", node1/item[2])
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