xml declaration/header missing when generating xml?

709 Views Asked by At

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:

enter image description here

How can i add the xml version and encoding header? Thanks for the help!

1

There are 1 best solutions below

0
wasmachien On BEST ANSWER

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.