Grails render as XML generates an unwanted class element
I am rendering a command class as XML via
render foo as XML
where foo is an instance of the command class.
Thi开发者_如何学编程s successfully returns an XML for the objects value. However, the generated XML also contains a class element, e.g., my.package.ClassNameOfCommandObject
This also happens when I do the same for a standard domain class, as well as when I use the encodeAsXML() method of the command object.
How can eliminate the element from the generated XML?
I took a look through the XML converter docs, they don't seem to have the option you need. The simplest way (though a hack) is to simply generate the XML, and do string substitution in the resulting string.
This thread may be of use - it goes a bit into internals of the process and where you could overwrite things.
Of course, you can always just use markupbuilder if you need something very custom. This post has an example.
精彩评论