I have been struggling concatenating child node values using XPath
.
We have an XML file with a parent node and three child nodes each, what I am trying to achieve is to get only two of these child nodes and concatenate their values as CHILDNODE1 [CHILDNODE2]
E.g. The parent node would look like this
<Term>
<ID>24</ID>
<Code>abc</Code>
<Name>xyz</Name>
</Term>
XPath Call: Code[Name]
Result: abc[xyz]
Almost missed to mention, I am trying to get an ArrayList
as outcome for all the similar nodes, i.e. Instead of looping over these nodes and concatenate one by one, get all these values in one XPath query (not sure that's even possible).
I would like to know if this is possible at all and some suggestions/examples would be really great.
If it cannot be achieved suing XPath
then would be the other options.