Howdy, Stranger!

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

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Trouble with loadXML from string

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

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

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?

Comments

Sign In or Register to comment.