Skip to content

Instantly share code, notes, and snippets.

@nobeans
Created March 14, 2011 16:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nobeans/869409 to your computer and use it in GitHub Desktop.
Save nobeans/869409 to your computer and use it in GitHub Desktop.
def map = [a:'A', b:'B']
def sw = new StringWriter()
def builder = new groovy.xml.MarkupBuilder(sw)
builder.hoge {
map.each { key, value ->
"$key"(value)
}
}
println sw.toString()
@nobeans
Copy link
Author

nobeans commented Mar 14, 2011

Result:

<hoge>
  <a>A</a>
  <b>B</b>
</hoge>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment