验证XML合法性(DTD限制XML内容)的html代码页面---用IE浏览器打开
<html>
<body>
<script language="JavaScript">
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.validateOnParse="true"
xmlDoc.load("note_dtd_error.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)
</script>
</body>
</html>
<html>
<body>
<script language="JavaScript">
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")
xmlDoc.async="false"
xmlDoc.validateOnParse="true"
xmlDoc.load("note_dtd_error.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)
</script>
</body>
</html>
本文介绍如何使用JavaScript验证XML文件的DTD限制内容的有效性,通过展示具体的HTML代码页面实例,包括引入XMLDOM对象、加载XML文件、解析错误处理等关键步骤。
1723

被折叠的 条评论
为什么被折叠?



