Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

encoding in an XML DOM

Status
Not open for further replies.

wduty

Programmer
Jun 24, 2000
271
US
Does anyone know how to set the encoding of an XmlDocument object?

I am building and modifying an XML DOM in a java program heavily working with the XML API with no problems (except truly ghastly coding). But when I write the XML to a file and open the it in a text editor, the document structure is well-formed and valid except that the encoding is set (by the java XML processor apparently) to cP1252:

[red]<?xml version=&quot;1.0&quot; encoding=&quot;Cp1252&quot;?>[/red]

I can change this encoding manually to:

[red]<?xml version=&quot;1.0&quot; encoding=&quot;windows-1252&quot;?>[/red]

or

[red]<?xml version=&quot;1.0&quot; encoding=&quot;iso-8859-1&quot; ?>[/red]

and the document will then show up in a IE but that is not a very good solution. I don't know much about encodings but if anyone know how to set this from the java application or any other related suggestions, I would appreciate it greatly.

I've looked through the com.sun.xml.tree API and can't find anything that looks like a possible method. [sig]<p>--Will Duty<br><a href=mailto:wduty@radicalfringe.com>wduty@radicalfringe.com</a><br><a href= > </a><br> [/sig]
 
If anyone was going to post, thanks but I figured it out. If interested, it's in one of the write methods:

XmlDocument.write(Writer w, String encoding)

Anyone else out there working with the java XML classes? Thoughts or comments in general welcome. [sig]<p>--Will Duty<br><a href=mailto:wduty@radicalfringe.com>wduty@radicalfringe.com</a><br><a href= > </a><br> [/sig]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top