xml - Get nth child node without knowing node name Groovy -
i have xml this:
<node1> <node2> <node3> <node4> <node5> <node6> </node6> <node7> </node7> </node5> </node4> </node3> </node2> </node1>
how can name of 6th node - assuming don't know node's name "node6"?
i have:
def text = <xml above> def list = new xmlslurper().parsetext(text)
thanks in advance.
how about:
def text = <xml above> def node = new xmlslurper().parsetext(text)[0] 5.times { node = node.children()[0] } assert node.name() == "node6"
Comments
Post a Comment