[jdom-interest] XML escaping and unescaping

Per Norrman per.norrman at austers.se
Mon Dec 6 23:01:09 PST 2004


John Caron wrote:
> David Wall wrote:
> 
>> You are trying to put a CTRL-A character in, and that's not a legal value
>> for XML data.  Are you trying to store a "1" character?  If so, just use
>> Element.setText("1");
>>  
>>
> my problem is that im trying to send an arbitrary string across the wire 
> with XML. Sometimes its got weird stuff in it, but id like it to show up 
> on the other side anyway just as it is. Im unclear how to serialize it. 
> I thought that was similar to your previous question.
> 
One approach would be to use Base64 encoding and decoding, a very common
solution in XML specifications and applications for transferring binary
data.

You can find a Base64 codec here: http://jakarta.apache.org/commons/codec/

/pmn



More information about the jdom-interest mailing list