--- Thierry Hanser wrote:
>
>
> Actually as long as you do not write an XML document to
> an output there is no point in dealing with encoding explicitely.
> Your <author> content data is stored in a JAVA String (using JAVA's
> internal Unicode encoding). Therefore you don't have to worry about
> encoding as long as you deal with the JAVA document. 

Thats true, but of course I write it out and it is going to be parsed.
Forgot to mention it. But good point.

>Once you wantto write
> out your document (e.g. to a file), then you may use an XMLWriter that will
> take care of performing the appropriate encoding and escape sequences. You
> may also use CDATA if you want to avoid escape sequences in your output.

Thanxs, that is what I was looking for. 
Just did not look at the right place ;-)

> See the XMLWriter class to find out all the encoding and
> indenting options you may use for your output.
>
> Here is your example:
>
> import org.dom4j.*;
> import org.dom4j.io.*;
>
> public class Test
> {
>     public static void main(String[] argv) throws java.io.IOException
>     {
>       // creating the document
>         Document document = DocumentHelper.createDocument();
>         Element root = document.addElement( "root" );
>
>       // writing an author with normal parsed character data
>         Element author1 = root.addElement( "author" ).addText("Hello <
> World");
>
>       // writing an author with non parsed character data (CDATA)
>         Element author2 = root.addElement( "author" ).addCDATA("Hello <
> World");
>
>       // writing the document to the standard output using the default XMLWriter
>       // (default encoding = utf-8, default endenting = no indenting)
>       // note the '<' character being automatically converted to &lt; inthe
> output new XMLWriter().write(document);
>     }
> }
>
> Good luck,
>
> Thierry



-------------------------------------------------------
This sf.net email is sponsored by: See the NEW Palm
Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to