[jdom-interest] Why does setText(" ") not do what I want?

John Monaco john.monaco at gmx.de
Tue Oct 24 06:43:13 PDT 2006


Hi,

I read "Why does setText(" ") not do what I want?" in FAQ but I do not understand the 2 solutions.

>The solution is to pass regular Unicode characters to the setText()
>method or, if you have text data that you want to be interpreted as XML, 
>pass it through an XML parser before it goes into JDOM. This is what the
>SAXBuilder and DOMBuilder classes do.


I pass the characters with the Windows tool charmap.exe that produces unicode. It works fine with some unicode characters (for example Ç) but not with all. Alpha & # 945 ; or Beta & # 946 ; are not working, these are transferred to & amp ; # 945 ;


So the 2nd solution is to parse text data, in my case these are strings.
But how can I parse text data which is not in a XML format?


This is what I'm doing:

Element root = new Element("Rootelement");   
Document document = new Document(root);
root.addContent(new Element("FirstElement").setText(ContentElement));


In a Java servlet I get strings like ContentElement from a html form which can contain unicode characters like '& # 945 ;' Then I build an XML document with these strings using method setText. The method transforms '& # 945 ;' to '& amp ; # 945 ;'


Are there any other solutions?

Thanks in advance,
John

-- 
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen! 
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer


More information about the jdom-interest mailing list