Hi,
Korrignu wrote:
> Hi,
>
> I'm working with XML file that contains HTML specials characters like
> "é".
>
> I use XStream to build objects according to xml file, but I can't handle
> this kind of stuff. This is my very simple code :
>
> String stoxml = xstream.toXML("a < b");
> System.out.println(stoxml);
> System.out.println(xstream.fromXML(stoxml));
>
> and it works fine :
> <string>a < b</string>
> a < b
>
> but if my code is :
> stoxml = xstream.toXML("é");
> System.out.println(stoxml);
> System.out.println(xstream.fromXML(stoxml));
>
> it becomes weird, it prints :
> <string>&eacute;</string>
> é
This is absolutely the correct result! You provide a String to XStream and
Xstream is able to convert it into proper XML and read it back. XStream does
not interpret the provided string in any way.
> and then if my xml file looks like :
> <blog author="Guilh é rme Silveira">
> <entry>
> <title>first</title>
> <description>My first blog entry.</description>
> </entry>
> <entry>
> <title>tutorial</title>
> <description>
> Today we have developed a nice alias tutorial. Tell your
> friends! NOW!
> </description>
> </entry>
> </blog>
>
> from your (modified) example, it raise an
> com.thoughtworks.xstream.io.StreamException: : unresolved: é
> (position:START_TAG <blog author='null'>@1:28 in
> java.io.InputStreamReader@157fb52)
>
> ...
>
> Have you an Idea ?
XML specification does not define this entity. You are getting an absolutely
correct exception from the XML parser, XStream is not even involved.
> Thanks for your time and your help.
Provide valid XML.
- Jörg
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email