wrt: XmlUtil.serialize(xml.toString()) You are seeing the expected behavior. If you look at the javadoc for XmlNodePrinter, you'll see it does take a String parameter but it expects that to be in xml format. If you take a look at the XmlParser nodes, you'll see that they don't print out in xml. Just try "println xml.toString()".
You're earlier code runs fine for me. I am not sure where the error message is coming from. XmlUtil.serialize does indeed use XmlNodePrinter and sets preserveWhiteSpace but that should work fine. It almost looks like you have a mixture of jars from different Groovy versions or are compiling with one version and running with another. Can you add the following line to your script and see what output you get? println getClass().classLoader.rootLoader.URLs Cheers, Paul. . On Thu, Aug 18, 2016 at 8:57 PM, Paul King <[email protected]> wrote: > ---------- Forwarded message ---------- > From: GroovyBeginner <[email protected]> > Date: Thu, Aug 18, 2016 at 8:17 PM > Subject: Issue with XML Serialization > To: [email protected] > > > Am facing the issue when serialising the node object. Here is my code > > > but getting an error groovy.util.XmlNodePrinter.setPreserveWhitespace(Z)V > and when used getting an > > > > -- > View this message in context: > http://groovy.329449.n5.nabble.com/Issue-with-XML-Serialization-tp5734724.html > Sent from the Groovy Dev mailing list archive at Nabble.com.
