Trouble with loadXML from string
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   joder_illi
Posted On:   Wednesday, August 29, 2007 06:56 AM

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"); 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," + encodeURIC   More>>


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");
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");


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?

   <<Less

Re: Trouble with loadXML from string

Posted By:   Axel_Richter  
Posted On:   Wednesday, August 29, 2007 07:17 AM

Hi



Microsoft's Internet Explorer, as of version 7, does not support data: URIs. Look at: http://en.wikipedia.org/wiki/Data:_URI_scheme.



greetings



Axel
About | Sitemap | Contact