Solved
Forum Discussion
nmrao
Champion Level 3
Would you mind to explain what exactly you are trying to achieve? or why do you want to do so? Reason being, if we know the object, there could be alternate better solutions.
evoks
7 years agoOccasional Contributor
Hi,
Thanks for your answer.
For each index, I want the tag tree to each node, from the "Body" node
Thanks for your answer.
For each index, I want the tag tree to each node, from the "Body" node
- evoks7 years agoOccasional 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.
- nmrao7 years agoChampion Level 3sorry to come back again with same question. I already understand that part, you just repeated the same. But you did not explain why do you want to so?
- PaulMS7 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
- 10 months agochrisaltair
- 7 years agodemosoapuser
- 5 years agoskaushik9
- 9 years agobabusr01