File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Change Encoding of XML document." Watch "Change Encoding of XML document." New topic
Author

Change Encoding of XML document.

L Goundalkar
Ranch Hand

Joined: Jul 05, 2001
Posts: 395
Hi,

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.


<b>L G Goundalkar</b><br /> <a href="mailto:lggoundalkar@yahoo.com" rel="nofollow">lggoundalkar@yahoo.com</a> <br />Sun Certified Programmer for Java 2 Platform.<br />Sun Certified Web Component Developer for J2EE.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12682
    
    5
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.
Bill


Java Resources at www.wbrogden.com
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Change Encoding of XML document.
 
Similar Threads
default namespaces are being dropped when sent through a web service
Generate XML / DOM using XSL and Xpath
WebSphere 6.1 encoding exception
Not able to delete xml files after reading
need to update entry in XML file.