I use groovy.xml.MarkupBuilder to create an XML response, but it produces a very printed result that is not needed in the production process.
def writer = new StringWriter() def xml = new MarkupBuilder(writer) def cities = cityApiService.list(params) xml.methodResponse() { resultStatus() { result(cities.result) resultCode(cities.resultCode) errorString(cities.errorString) errorStringLoc(cities.errorStringLoc) } }
This code creates:
<methodResponse> <resultStatus> <result>ok</result> <resultCode>0</resultCode> <errorString></errorString> <errorStringLoc></errorStringLoc> </resultStatus> </methodResponse>
But I donβt need any identification - I just need a simple one-line text :)
xml grails groovy xml-serialization
Oleksandr
source share