OK. It is easy. The setText method does take care of it. I added the CDATA instead of Text back when I was using xml4j. Xerces works differently. Unfortunately I now have this behavior:
 
String property = ">";
Text textValue = doc.createTextNode(property);
 
String XMLValue = serialized doc;
 
Text textValue = superdoc.createTextNode(XMLValue);
 
The result is ">" - not really what I'm hoping for.
 
Any thoughts?
-----Original Message-----
From: Mark Sizer
Sent: Monday, March 19, 2001 3:05 PM
To: '[EMAIL PROTECTED]'
Subject: entity reference help, please!

I've spent all day trying to find out how to replace characters with entity references and have had no luck. I don't even want to use custom entity references, just &amp, &lt, and &gt so the parser won't choke reading what I'm outputting.
 
One would think that the Text node setText/getText methods would take care of it (or at least throw an exception if you give it characters that will break the parser), but it doesn't.
 
How do I convert a Java String from raw characters to an XML-safe representation?
 
Thanks for any help,

Mark R. Sizer,
CyberCrop.com

P.S. Is this as easy as I think it should be and I'm just really stupid today? Meanwhile, I'm going to write the code myself.

Reply via email to