Hi Alession,

when you write your data, it is a good idea not to write it directly  
to a stream/file, but instead
use an OutputStreamWriter which does the charset conversion for you.  
See code below.

-- Richard

     /**
      * Writes the document to the given stream. The caller is  
responsible for
      * closing the stream afterwards.
      *
      * @param fow
      * @param doc
      * @throws IOException
      */
     static public
     void dumpToStream(
                        OutputStream fow,
                        Document doc)
     throws IOException
     {
         String encoding = doc.getXMLEncoding();

         if (encoding == null) {
             encoding = "UTF-8";
         }

         Writer osw = new BufferedWriter(
                 new OutputStreamWriter(fow, encoding));
         XMLWriter writer = new XMLWriter(osw,
                 new OutputFormat("  ", true, encoding));
         writer.write(doc);
         writer.flush();
     }




Am 27.10.2008 um 22:47 schrieb Alessio Camaroto:
> Hi I'm Alessio,
> I have a problem of encoding with files XML. I need to read an XML  
> file and split it into XML n-files so I read it with SAXReader, I  
> create n-new files and I write into them with SAXWriter.
> Those files aren't XML valid because contain some characters are  
> not into the encoding type, UTF-8. What's wrong ?
>
> Thanks a lot
>  Alessio
> ---------------------------------------------------------------------- 
> ---
> This SF.Net email is sponsored by the Moblin Your Move Developer's  
> challenge
> Build the coolest Linux based applications with Moblin SDK & win  
> great prizes
> Grand prize is a trip for two to an Open Source event anywhere in  
> the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/ 
> _______________________________________________
> dom4j-user mailing list
> dom4j-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/dom4j-user
>

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
dom4j-user mailing list
dom4j-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to