Groovy allows you to easily generate XML using the groovy.xml.MarkupBuilder class. We’ll show you the basic mechanics of that class and then look at how Spring’s XML configuration format maps to the bean builder syntax used in chapter 14, because the mapping is similar.
Generating XML text is trivial with the MarkupBuilder class. We’ll demonstrate with a simple example, as shown in the following listing.
This will create the file test.xml containing the content, shown in the following listing.