Re: Use ampersand character in setText

Robin Rosenberg <[email protected]>
Newsgroups gmane.comp.java.jdom.general
Message-ID <[email protected]>
Andrea Pacini skrev 2011-12-16 10.43:
> Hi,
> 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:
>
> &amp;test
>
> Where is the error ?

It's in your interpretation/the writing in the FAQ.

It should be more like "Why does setText("&#160;") not output a NO-BREAK SPACE
character into the XML document".

There is no difference in Java between "&test" and "\u0026test", except that the
latter is harder to read. Both translates into the exact same bytecode.

The FAQ could be complemented with the corrected call, e.g. setText("\u00a0"); To make
things more confusing Java uses hexadecimal code units while XML uses decimal code points.

-- robin
_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.