  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | Why does setText( " ") not do what I want? | Why does setText( " ") not do what I want? 2006-10-24 - By John Monaco
Back 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 __ ____ ____ ____ ____ ____ ____ ____ ____ ____ To control your jdom-interest membership: http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
|
|
 |