O'Reilly logo

Grails in Action, Second Edition by Glen Smith and Peter Ledbrook

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix C. XML and Spring builders

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.

C.1. XML generation with MarkupBuilder

Generating XML text is trivial with the MarkupBuilder class. We’ll demonstrate with a simple example, as shown in the following listing.

Listing C.1. Using MarkupBuilder to generate XML text

This will create the file test.xml containing the content, shown in the following listing.

Listing C.2. Creating ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required