[jdom-interest] Use ampersand character in setText
Mattias Jiderhamn
mj-lists at expertsystems.se
Fri Dec 16 04:14:24 PST 2011
If you want to create invalid XML you probably don't want to try to
force an XML API to help you out...
</Mattias>
----- Original Message -----
Subject: Re: [jdom-interest] Use ampersand character in setText
Date: Fri, 16 Dec 2011 12:58:56 +0100
From: Andrea Pacini <pacionet at gmail.com>
>
> We have necessity to write, in the final XML, the string &test and
not the
> string &test
> How can we do ?
>
> 2011/12/16 Grzegorz <grzegorz.kaczor at gmail.com>
>
>> according to Jdom FAQ ( http://www.jdom.org/docs/faq.html#a0290 ) , I
>>> tried to write the string
>>>
>>> &test
>>>
>>> using this statement:
>>>
>>> root.setText("\u0026test");
>>>
>>> where \u0026 is the Unicode code for ampersand character.
>>>
>>> The output is:
>>>
>>> &test
>>>
>>> Where is the error ?
>>>
>>
>> There is no error. What is wrong? It is a special character in XML
and as
>> such it must be escaped.
>>
>> Regards,
>> Grzegorz
>>
>
>
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com
More information about the jdom-interest
mailing list