Skip to content

Instantly share code, notes, and snippets.

@ppazos
Created April 20, 2018 06:39
Show Gist options
  • Save ppazos/1acf4cf9c2598ff8a55297ee7b5a09df to your computer and use it in GitHub Desktop.
Save ppazos/1acf4cf9c2598ff8a55297ee7b5a09df to your computer and use it in GitHub Desktop.
import groovy.util.XmlSlurper
def xml = new XmlSlurper().parseText('''
<issues>
<issue>
<id>1</id>
<priority>1</priority>
</issue>
<issue>
<id>2</id>
<priority>2</priority>
</issue>
</issues>
''')
def p = '1'
def priorityIssue = xml.'**'.find { issue ->
issue.priority.text() == p
}
xml.issue[0].replaceNode { node ->
mkp.yield(node)
hermano('lamano')
}
println xml.children()*.name()
println xml.find { it.name() == 'hermano' }
groovy.xml.XmlUtil.serialize( xml )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment