Created
January 23, 2012 05:04
-
-
Save osima/1660755 to your computer and use it in GitHub Desktop.
test XmlParser and XmlNodePrinter
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
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