Rendering XML output in Grails with extra markup?

sadini

New Member
I have read the docs on how to render XML in Grails (both Grails 1.x and 2.x), and found some sparse documentation on how to use a template, but haven't been able to leverage that to get what I'm looking for.I have a set of objects I need to use to populate a specific XML format. Here's the XML I need as an output:\[code\]<?xml version="1.0" encoding="UTF-8"?><response> <status>0</status> <data> <record> <fieldId>fieldId1</fieldId> <name>name1</name> <type>Text</type> </record> <record> <fieldId>fieldId2</fieldId> <name>Name2</name> <type>Number</type> </record> </data></response>\[/code\]Assuming my objects are flat, with \[code\]fieldId\[/code\], \[code\]name\[/code\], and \[code\]type\[/code\] fields, how would I generate this output? As a secondary question, if the answer uses templating, where does the template reside? In \[code\]grails-app/views\[/code\]?
 
Back
Top