A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
Java 8 in Action
this week in the
XML and Related Technologies
Change Encoding of XML document.
Joined: Jul 05, 2001
Feb 26, 2005 06:27:00
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.
Document doc = new DocumentImpl(); Element rootNode = doc.createElement("parent"); doc.appendChild(rootNode);
How can i change the encoding of above document object.
Thanks for your time.
<b>L G Goundalkar</b><br /> <a href="mailto:email@example.com" rel="nofollow">firstname.lastname@example.org</a> <br />Sun Certified Programmer for Java 2 Platform.<br />Sun Certified Web Component Developer for J2EE.
Author and all-around good cowpoke
Joined: Mar 22, 2000
Feb 26, 2005 06:56:00
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.
Java Resources at
I agree. Here's the link:
subject: Change Encoding of XML document.
Generate XML / DOM using XSL and Xpath
Not able to delete xml files after reading
WebSphere 6.1 encoding exception
need to update entry in XML file.
default namespaces are being dropped when sent through a web service
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014