Created
August 27, 2010 13:37
-
-
Save ehynds/553364 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// based heavily off: | |
// https://sites.google.com/a/van-steenbeek.net/archive/explorer_domparser_parsefromstring | |
if( typeof window.DOMParser === "undefined" ){ | |
window.DOMParser = function(){}; | |
window.DOMParser.prototype.parseFromString = function(str, contentType){ | |
if(typeof ActiveXObject !== 'undefined'){ | |
var xmldata = new ActiveXObject('MSXML.DomDocument'); | |
xmldata.async = false; | |
xmldata.loadXML(str); | |
return xmldata; | |
} else if(typeof XMLHttpRequest !== 'undefined'){ | |
var xmldata = new XMLHttpRequest; | |
if(!contentType){ | |
contentType = 'application/xml'; | |
} | |
xmldata.open('GET', 'data:' + contentType + ';charset=utf-8,' + encodeURIComponent(str), false); | |
if(xmldata.overrideMimeType) { | |
xmldata.overrideMimeType(contentType); | |
} | |
xmldata.send(null); | |
return xmldata.responseXML; | |
} | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment