This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
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..