📄 dom_validate.asp@output=print
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>XML DOM - Validate XML</title>
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />
<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />
<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>
<script language="JavaScript" type="text/javascript">
function validateXML()
{
// code for IE
if (window.ActiveXObject)
{
var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.loadXML(document.all("validxml").value);
if(xmlDoc.parseError.errorCode!=0)
{
txt="Error Code: " + xmlDoc.parseError.errorCode + "\n";
txt=txt+"Error Reason: " + xmlDoc.parseError.reason;
txt=txt+"Error Line: " + xmlDoc.parseError.line;
alert(txt);
}
else
{
alert("No errors found");
}
}
// code for Mozilla, Firefox, Opera, etc.
else if (document.implementation && document.implementation.createDocument)
{
var parser=new DOMParser();
var text=document.getElementById("validxml").value;
var xmlDoc=parser.parseFromString(text,"text/xml");
if (xmlDoc.documentElement.nodeName=="parsererror")
{
alert(xmlDoc.documentElement.childNodes[0].nodeValue);
}
else
{
alert("No errors found");
}
}
else
{
alert('Your browser cannot handle this script');
}
}
</script>
</head>
<body>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
<h1>XML DOM Validation</h1>
<a href="dom_examples.asp"><img border="0" src="../images/btn_previous.gif" alt="prev" width="100" height="20" /></a>
<a href="default.asp"><img border="0" src="../images/btn_next.gif" alt="next" width="100" height="20" /></a>
<hr />
<h2>XML Errors will Stop you
</h2>
<p><b>Errors in XML documents will stop your XML program.</b>
</p>
<p>The W3C XML specification states that a program should not continue to
process an XML document if it finds an error. The reason is that XML
software should be easy to write, and that all XML documents should be
compatible.
</p>
<p>With HTML it was possible to create documents with lots of errors (like when
you forget an end tag). One of the main reasons that HTML browsers are so big
and incompatible, is that they have their own ways to figure out what a document
should look like when they encounter an HTML error.
</p>
<p>With XML this should not be possible.
</p>
<hr />
<h2>Syntax-check your XML</h2>
<p>To help you syntax-check your xml, we have created
an XML validator.</p>
<p>Paste your XML in the text area below, and syntax-check it by pressing the
"Validate" button.</p>
<form action="">
<p>
<textarea id="validxml" rows="10" cols="75">
<?xml version="1.0" ?>
<note>
<to>Tove</to>
<from>Jani</Ffrom>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
</textarea>
<br />
<input type="button" value="Validate" onclick="validateXML()" />
</p>
</form>
<hr />
<h2>Syntax-check your XML File</h2>
<p>You can also syntax-check your XML file by typing the URL of your file into the
input field below, and then press the "Validate" button</p>
<form action="validator.asp" target="_blank" method="post">
<p>Filename:
<br />
<input type="text" name="xmlfile" size="50" value="http://www.w3schools.com/dom/note_error.xml" />
<br />
<input type="submit" value="Validate" />
</p>
</form>
<p>If you want to validate an error-free XML file, you can paste the following address
into the filename field: http://www.w3schools.com/dom/cd_catalog.xml</p>
<p><b>Note:</b> If you get the error "Access denied" when accessing this file,
it is because your browser security settings do not allow access across domains.</p>
<hr />
<a href="dom_examples.asp"><img border="0" src="../images/btn_previous.gif" alt="prev" width="100" height="20" /></a>
<a href="default.asp"><img border="0" src="../images/btn_next.gif" alt="next" width="100" height="20" /></a>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -