I am using the following code to dynamically generate xml
def testXML(){
render( contentType:"text/xml" ) {
book() {
author( name:'author')
}
}
}
The xml file is missing the xml header
<?xml version="1.0" encoding="UTF-8"?>
The generated xml looks as follows:
How can i add the xml version and encoding header? Thanks for the help!
As long as your file is UTF-8 encoded the declaration should not be necessary. Maybe try checking the source of the web page, it could be that your browser does not display it. If it's really not there, try adding ;charset=utf-8
to your content type.