Skip to content

Instantly share code, notes, and snippets.

@linuxoid69
Last active October 21, 2015 13:31
Show Gist options
  • Save linuxoid69/16114a32425b1d449949 to your computer and use it in GitHub Desktop.
Save linuxoid69/16114a32425b1d449949 to your computer and use it in GitHub Desktop.
groovy xml parser
task parseXml() {
def fileXml = new File('xmlexample.xml')
def resources = new XmlSlurper().parseText(fileXml.getText())
if (resources.string[0].@name == 'host'){
resources.string[0]= 'localhost'
}
def f = XmlUtil.serialize(resources)
def of = new File('xmlexample2.xml')
of.write(f, "UTF-8")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment