This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Change Encoding of XML document. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Change Encoding of XML document." Watch "Change Encoding of XML document." New topic

Change Encoding of XML document.

L Goundalkar
Ranch Hand

Joined: Jul 05, 2001
Posts: 395

How to change the encoding of XML document using Java program.
I am using following code snippet to create document object and it returns me the prolog as "<?xml version="1.0" encoding="ISO-8859-1"?>"

I am using org.apache.xerces.dom parser.

How can i change the encoding of above document object.

Thanks for your time.

William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 13018
How are you doing output of this document to a file? It seems to me that internally the DOM will all be in Unicode and the file encoding is established in the output method. Look at the Transformer properties - there is an ENCODING property.
I agree. Here's the link:
subject: Change Encoding of XML document.
It's not a secret anymore!