注意该死的ie多版本的问题
复制代码 代码如下:
function loadXML(xmlString) {
var xmlDoc = null;
if (!window.DOMParser && window.ActiveXObject) {
var xmlDomVersions = ['MSXML.2.DOMDocument.6.0', 'MSXML.2.DOMDocument.3.0', 'Microsoft.XMLDOM'];
for (var i = 0; i < xmlDomVersions.length; i++) {
try {
xmlDoc = new ActiveXObject(xmlDomVersions[i]);
xmlDoc.async = false;
xmlDoc.loadXML(xmlString);
break;
} catch (e) {
}
}
}
else if (window.DOMParser && document.implementation && document.implementation.createDocument) {
try {
domParser = new DOMParser();
xmlDoc = domParser.parseFromString(xmlString, 'text/xml');
} catch (e) {
}
}
else {
return null;
}
return xmlDoc;
}
复制代码 代码如下:
function loadXML(xmlString) {
var xmlDoc = null;
if (!window.DOMParser && window.ActiveXObject) {
var xmlDomVersions = ['MSXML.2.DOMDocument.6.0', 'MSXML.2.DOMDocument.3.0', 'Microsoft.XMLDOM'];
for (var i = 0; i < xmlDomVersions.length; i++) {
try {
xmlDoc = new ActiveXObject(xmlDomVersions[i]);
xmlDoc.async = false;
xmlDoc.loadXML(xmlString);
break;
} catch (e) {
}
}
}
else if (window.DOMParser && document.implementation && document.implementation.createDocument) {
try {
domParser = new DOMParser();
xmlDoc = domParser.parseFromString(xmlString, 'text/xml');
} catch (e) {
}
}
else {
return null;
}
return xmlDoc;
}
标签:
跨浏览器,字符串转xml对象
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件!
如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
狼山资源网 Copyright www.pvsay.com
暂无“js跨浏览器实现将字符串转化为xml对象的方法”评论...