Hi,
Try something like that :
XMLWriter writer = new XMLWriter(out, new OutputFormat(" ", true, "UTF-8"));
writer.write(doc);
writer.flush();
Where out is an OutputStream and doc is a dom4j Document object.
Yes it works this way, but only if you pass here an OutputStream. If you pass a Writer object instead (using an other constructor) it'll not function:
OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding("UTF-8"); FileWriter fileWriter = new FileWriter(outFile); XMLWriter xmlWriter = new XMLWriter(fileWriter, format); xmlWriter.write(doc);
I think it's a correct way of using the API, but I still get ANSI encoding. As I'm aware it's not possible to change the Writer's encoding as far as it's already created. ...and so the API doesn't do it. The encoding was set for the OutputFormat is simply not used in this case.
So it's an inconsistent functioning of the API or we can say it's a bug.
Best regards,
-- Barnabas Davoti Information Architect empolis Scandinavia phone: +47 2414-7976 mobile: +47 4161-8058
------------------------------------------------------- This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more http://productguide.itmanagersjournal.com/guidepromo.tmpl _______________________________________________ dom4j-user mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/dom4j-user