IE's responseXML.getElementsByTagName() unable to handle non English character ?

Posted by trix on Stack Overflow See other posts from Stack Overflow or by trix
Published on 2010-03-16T06:53:57Z Indexed on 2010/03/16 6:56 UTC
Read the original article Hit count: 202

Filed under:

I have a javascript that does this (http is your XMLHttpRequest object)

var r = http.responseXML.getElementsByTagName('item');

The issue is variable r is always an empty list if the response contains non-English character (r.length is 0).

The response header is correctly set Content-Type: text/xml;charset=ISO-8859-1

This is what the response from the webserver looks like

<?xml version='1.0' encoding='UTF-8'?>
<d>
<r>
<item value="jmob" label="John Möb"/>
</r>
</d>

It happens only in IE (both IE6 and IE8), works in Firefox and Chrome. If items contain only English characters, it works fine.

Is there a workaround for this ?

© Stack Overflow or respective owner

Related posts about JavaScript