+ -
当前位置:首页 → 问答吧 → 关于读取xml文件的问题

关于读取xml文件的问题

时间:2010-11-02

来源:互联网

JScript code

var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async = "false";
xmlDoc.validateOnParse = "true";
xmlDoc.load("xmlFile.xml");

document.write("<br/>Error Code:");
document.write(xmlDoc.parseError.errorCode);
document.write("<br/>Error Reason:");
document.write(xmlDoc.parseError.reason);
document.write("<br/>Error line:");
document.write(xmlDoc.parseError.line);



写了这样的代码,之后在ie中是正常的能够检测xml的错误,可是在火狐下就不可以了,错误出在第一行,
请问在火狐里应该怎么写?

作者: bleach880204   发布时间: 2010-11-02

JScript code

var oXmlDom = document.implementation.createDocument("", "", null);
oXmlDom.load("xmlFile.xml");
oXmlDom.onload = function () {
    if(oXmlDom.documentElement.tagName == "parsererror")
        alert(oXmlDom.documentElement.firstChild.nodeValue);
};

作者: hookee   发布时间: 2010-11-02

解释一下吧,1楼的

作者: bleach880204   发布时间: 2010-11-02