编辑下面的代码:【加编码】
<html> <head> <script> function loadXMLDocErr(dname) { try //Internet Explorer { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); xmlDoc.async=false; xmlDoc.load(dname); if (xmlDoc.parseError.errorCode != 0) { alert("Error in line " + xmlDoc.parseError.line + " position " + xmlDoc.parseError.linePos + "\nError Code: " + xmlDoc.parseError.errorCode + "\nError Reason: " + xmlDoc.parseError.reason + "Error Line: " + xmlDoc.parseError.srcText); return(null); } } catch(e) { try //Firefox { xmlDoc=document.implementation.createDocument("","",null); xmlDoc.async=false; xmlDoc.load(dname); if (xmlDoc.documentElement.nodeName=="parsererror") { alert(xmlDoc.documentElement.childNodes[0].nodeValue); return(null); } } catch(e) {alert(e.message)} } try { return(xmlDoc); } catch(e) {alert(e.message)} return(null); } </script> </head> <body> <script> xmlDoc=loadXMLDocErr("note_error.xml"); </script> </body> </html>
结果: 【此窗口】 帮助?
Try it Yourself - © 自强学堂