Trouble with loadXML from string

Hi, I got some trouble parsing an XML response from a string in IExplorer. The javascript code that does the parsing looks like this:

if (typeof DOMParser == "undefined") {
DOMParser = function () {}
DOMParser.prototype.parseFromString = function (str, contentType) {
if (typeof ActiveXObject != "undefined") {
var d = new ActiveXObject("Microsoft.XMLDOM");
return d;
} else if (typeof XMLHttpRequest != "undefined") {
var req = new XMLHttpRequest;"GET", "data:" + (contentType || "application/xml") +";charset=utf-8," + encodeURIComponent(str), false);
if (req.overrideMimeType) {
return req.responseXML;
var xml = (new DOMParser()).parseFromString(text, "text/xml");

where "text" (in the last line) is a string with the response I recieve from the server. In firefox and opera it works fine, but in Iexplorer "xml"(in the last line) is a empty xml document no matter what I do input as "text". What am I doing wrong?


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!