Solved
Forum Discussion
evoks
Occasional Contributor
(sorry for my english, I'm studying it at school).
To be more precise, if I have the following XML file :
<Body> <parent_Node_A>value_A</parent_Node_A> <parent_Node_B> <children_Node_B1>value_B1</children_Node_B1>
<children_Node_B2>value_B2</children_Node_B2>
</parent_Node_B> <parent_Node_C>value_C</parent_Node_C> <parent_Node_D> <children_Node_D>value_D</children_Node_D> </parent_Node_D> <parent_Node_E>value_E</parent_Node_E> </Body>
The goal is to capture all parent nodes to each value returned by the groovy script.
For the "value_B1", I have to capture its parent nodes and concatenate them :
"Body/parent_Node_B/children_NodeB1=value_B1"
Second example, for the "value_D" :
"Body/parent_Node_D/children_Node_D=value_D"
Third example, for the "value_E" :
"Body/parent_Node_E=value_E"
I hope I've been more explicit.
Thanks.
PaulMS
7 years agoSuper Contributor
This is similar to https://stackoverflow.com/questions/36179764/get-path-to-all-xmls-nodes
private static String getXPath(node) { if (node.parent().name() == node.name()) { return node.name() } return getXPath(node.parent()) + "/" + node.name() }
then use
output << getXPath(node)+'='+node.text()
- evoks7 years agoOccasional Contributor
Thanks a lot for your answer, that's exactly what I needed !
Related Content
- 11 months agochrisaltair
- 7 years agodemosoapuser
- 9 years agobabusr01
Recent Discussions
- 13 days agoemoya