Xpath 1 (dom4j) - concatenate text values of multiple nodes

503 views Asked by At

Is there a way to concatenate text values of several nodes using Xpath 1? I know what in Xpath 2 there's a cool string-join function, but dom4j supports only first version.

For example I have the following xml:

<root>
    <item>a</item>
    <item>b</item>
    <item>c</item>
</root>

I want to get (for example) "a,b,c" string using Xpath 1. Is it possible?

UPD: item count is unknown

1

There are 1 answers

4
splash58 On

if you exactly know the structure you can

concat(//item[1],',',//item[2],',',//item[3])

result

String='a,b,c'