Skip to content

Instantly share code, notes, and snippets.

@ivanoronee
Created April 8, 2017 16:10
Show Gist options
  • Save ivanoronee/ec2490de1f4158d1d1bd8c77151f871d to your computer and use it in GitHub Desktop.
Save ivanoronee/ec2490de1f4158d1d1bd8c77151f871d to your computer and use it in GitHub Desktop.
import groovy.xml.*
def collection = [
[ key:'tim', value:null ],
[ key:'brenda', value:32 ]
]
def process = { binding, element ->
binding."${element.key}"( element.value )
}
println XmlUtil.serialize( new StreamingMarkupBuilder().with { builder ->
builder.bind { binding ->
data {
collection.each { e ->
process( binding, e )
}
}
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment