[jdom-interest] Adding String to Element where String contains an Element in String form

Elliotte Rusty Harold elharo at metalab.unc.edu
Wed May 29 04:40:16 PDT 2002


At 2:59 PM -0400 5/28/02, Alex Rosen wrote:
>JDOM doesn't really support what you're trying to do.
>
>When you set the text of an element to something like "3 < 4", it gets
>escaped to "3 &lt; 4" on output because "3 < 4" would be illegal XML. It
>happens that "<whatever/>" would not be illegal XML, but JDOM doesn't know
>that.
>

Not really. " 3 < 4" is text as is the string "<whatever/>". When you 
tell JDOM to add this text to a an element, JDOM does exactly that. 
It does not parse the text. "<whatever/>" is a string containing 11 
characters some of which happen to have reserved meanings in XML. But 
it is still a string, and JDOM treats it as one. The question is not 
what is legal and what is illegal. It is what have you told JDOM to 
do.
-- 

+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+
|          The XML Bible, 2nd Edition (Hungry Minds, 2001)           |
|             http://www.cafeconleche.org/books/bible2/              |
|   http://www.amazon.com/exec/obidos/ISBN=0764547607/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://www.cafeaulait.org/      |
|  Read Cafe con Leche for XML News: http://www.cafeconleche.org/    |
+----------------------------------+---------------------------------+



More information about the jdom-interest mailing list