I would like to insert comments into my xml document with a Groovy MarkupBuilder. How is it possible?
+1
A:
Try MarkupBuilderHelper.comment(). The linked page has an example.
Uses getMkp() to get the MarkupBuilderHelper.
LarsH
2010-10-26 11:33:12
+5
A:
You can use mkp.comment
like so:
def writer = new StringWriter()
def builder = new groovy.xml.MarkupBuilder( writer )
builder.cars {
mkp.comment "A comment"
ford( type:'escort')
ford( type:'fiesta')
}
println writer
Which prints:
<cars><!-- A comment -->
<ford type='escort' />
<ford type='fiesta' />
</cars>
The mkp.XXX
methods are described here
tim_yates
2010-10-26 11:33:54
thank you tim, it works!
jabal
2010-10-26 11:57:11