GPathResult to String without XML declaration
Use XmlParser
instead of XmlSlurper
:
def root = new XmlParser().parseText('<node/>')
new XmlNodePrinter().print(root)
Using new XmlNodePrinter(preserveWhitespace: true)
may be your friend for what you're trying to do also. See the rest of the options in the docs: http://docs.groovy-lang.org/latest/html/gapi/groovy/util/XmlNodePrinter.html.