GT2/Ejectable/node_modules/xml-parse-from-string/index.js

28 lines
684 B
JavaScript

module.exports = (function xmlparser() {
//common browsers
if (typeof self.DOMParser !== 'undefined') {
return function(str) {
var parser = new self.DOMParser()
return parser.parseFromString(str, 'application/xml')
}
}
//IE8 fallback
if (typeof self.ActiveXObject !== 'undefined'
&& new self.ActiveXObject('Microsoft.XMLDOM')) {
return function(str) {
var xmlDoc = new self.ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async = "false"
xmlDoc.loadXML(str)
return xmlDoc
}
}
//last resort fallback
return function(str) {
var div = document.createElement('div')
div.innerHTML = str
return div
}
})()