How to format xml from XmlSlurper?
I am looking for an easy, groovy way to format the string output of XmlSlurper.
I have found examples of using XmlParser and XmlNodePrinter. This won't work. XmlNodePrinter works with the Node from XmlParser, but not NodeChild from XmlSlurper.
// this prints nothing (nor does it throw an error)
def responseXml = new XmlSlurper().parseText(serviceResponse)
def writer = new StringWriter()
new XmlNodePrinter(new PrintWriter(writer)).print(responseXml)
def formattedResponse = writer.toString()
println "formattedResponse:" + formattedResponse
Is there anyway to get that to work with XmlSlurper?
Or better, is there a more groovy way of doing this?
That takes multiple lines/constructors to effectively do what I wish was just
xml.toIndentedString()
thanks,
Steve