Given this in a grails action:
def xml = { rss(version: \'2.0\') { ... } } render(contentType: \'application/rss+xml\', xml)
This is a simple way to pretty-print XML, using Groovy code only:
def xml = "" + "" def stringWriter = new StringWriter() def node = new XmlParser().parseText(xml); new XmlNodePrinter(new PrintWriter(stringWriter)).print(node) println stringWriter.toString()
results in: