Hi

I'm using groovy.util.Node to manipulate tree structures and than I store
the trees in XML format.

I need some nodes value not to be escaped.

Can you help me ?

Here's the code :

def nodeValue = '<![CDATA[you&me]]>'
Node rootNode = new Node(null, 'parent', [:], nodeValue)
rootNode.append(new Node(null, 'child', [:], nodeValue))

println groovy.xml.XmlUtil.serialize(rootNode) // & escaped to &amp;

def sw = new StringWriter()
new XmlNodePrinter(new IndentPrinter(sw, '', false)).print(rootNode)
println sw.toString()  // & escaped to &amp;

 And the output:

 <?xml version="1.0" encoding="UTF-8"?><parent>
&lt;![CDATA[you&amp;me]]&gt;  <child>&lt;![CDATA[you&amp;me]]&gt;</child>
</parent>

<parent>&lt;![CDATA[you&amp;me]]&gt;<child>&lt;![CDATA[you&amp;me]]&gt;</child></parent>

Thanks,

---
Jean-Christophe
<http://www.crealead.com>

Reply via email to