You can still use the XmlSlurper than use the serialize it and replace first replaceFirst
def oSalesOrderCollection = new XmlSlurper(false,false).parse(xas)
def xml = XmlUtil.serialize(oSalesOrderSOAPMarkup).replaceFirst("<\\?xml version=\"1.0\".*\\?>", "");
//Test the output or just print it
File outFile = new File("aes.txt")
Writer out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile), "UTF8"));
out.append(xml.toString())
out.flush()
out.close()
GroovyCore Snip :
/**
* Transforms the element to its text equivalent.
* (The resulting string does not contain a xml declaration. Use {@code XmlUtil.serialize(element)} if you need the declaration.)
*
* @param element the element to serialize
* @return the string representation of the element
* @since 2.1
*/
public static String serialize(Element element) {
return XmlUtil.serialize(element).replaceFirst("<\\?xml version=\"1.0\".*\\?>", "");
}
}