Last active
October 21, 2015 13:31
-
-
Save linuxoid69/16114a32425b1d449949 to your computer and use it in GitHub Desktop.
groovy xml parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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