Skip to content

Instantly share code, notes, and snippets.

@osima
Created January 23, 2012 05:04
Show Gist options
  • Save osima/1660755 to your computer and use it in GitHub Desktop.
Save osima/1660755 to your computer and use it in GitHub Desktop.
test XmlParser and XmlNodePrinter
def fix = { String text->
def out=''<<''
new StringReader(text).each{ out << it.trim() }
out.toString()
}
def xml = new StringWriter()
def builder = new groovy.xml.MarkupBuilder(xml)
builder.root {
p('hello world!')
}
def root = new XmlParser().parseText( xml.toString() )
def writer = new StringWriter()
new XmlNodePrinter(new PrintWriter(writer)).print(root)
assert fix(writer.toString())==fix(xml.toString())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment