thedesk/app/node_modules/xml-parse-from-string/index.js

28 lines
684 B
JavaScript
Raw Normal View History

2018-02-19 04:41:25 +11:00
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
}
})()