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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XMLDocument doesn't handle Umlauts / Encoding?

Status
Not open for further replies.

gdrenfrew

Programmer
Aug 1, 2002
227
GB
Hi there,

I'm trying to load data into my XMLDocument using javascript. The data can contain umlauts.

The data comes via an ASP page and is parsed through a stylesheet.

When I have my string of data and perform
oXMLAll.XMLDocument.loadXML(myData) the resulting oXMLAll.XMLDocument.xml is empty.

When I remove the umlauts from my data, the data is successfully loaded into the XMLDocument.

Do I need to set encoding on the XMLDocument? If so how do I do this?

Thank you.
 
Once you've decided to accept international characters, you have to explicitly change your encoding to UTF-8. In the case of a XSL transformation document, you need to set it on the document, as well as on it's xsl:eek:utput tag.

w3c.org said:
<!-- Category: top-level-element -->
<xsl:eek:utput
method = "xml" | "html" | "text" | qname-but-not-ncname
version = nmtoken
encoding = string
omit-xml-declaration = "yes" | "no"
standalone = "yes" | "no"
doctype-public = string
doctype-system = string
cdata-section-elements = qnames
indent = "yes" | "no"
media-type = string />

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Oops, didn't actually answer your question.

To set the encoding on an XmlDocument, you have to access it's XmlDeclaration object. This should be the first child node under the document.
Code:
XmlDeclaration xd = (XmlDeclaraion)myDoc.FirstChild;
xd.Encoding = "UTF-8";
I suspect, however, that the call to loadXML will overwrite this value -- you should ensure that the document you're trying to load has it's encoding set to UTF-8 as well.

Like I said earlier, once you go International, *everything* has to be internationalized. You can't rely on defaults.

Chip H.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top