Reputation: 2454
I am iterating an XML file like this:
new XmlSlurper().parseText(getServiceConfigXml())
.'**'
.findAll { it.name() == 'something' }
.each { node ->
println "attribute: ${node.attributes()} and body: ${node.text()}"
}
How can i acces the parent element of 'node' ?
Upvotes: 2
Views: 1939
Reputation: 2454
${node.parent().attributes()}
you can even do
${node.parent().parent().attributes()}
to access the parent of the parent node
Upvotes: 4