posted 14 years ago
There is a possibility of using another method.
You could use javax.xml.transform.Transformer with a DOM object and write your xml in to an attribute. This will escape the < and & etc. so that enclosing XML remains well formed. When parsing back from DOM the escaped XML comes out as original.
I tried this with StAX (cursor API) and works the same way.
Effectively, this works the same way as replacing < with < without having to do it yourself, if you you are already using any of these approaches to write your XML already..
Hope this helps..