📄 dom_errors.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 Parser Errors</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>
</head>
<body>
<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>
<h1>XML DOM Parse Error Object</h1>
<a href="dom_http.asp"><img border="0" src="../images/btn_previous.gif" alt="prev" width="100" height="20" /></a>
<a href="dom_errors_crossbrowser.asp"><img border="0" src="../images/btn_next.gif" alt="next" width="100" height="20" /></a>
<hr />
<p class="intro">Microsoft's parseError object can be used to retrieve error information from the
Microsoft XML parser.</p>
<p class="intro">To see how Firefox handles parser errors, check out the next
page of this tutorial.</p>
<hr />
<h2>The parseError Object
</h2>
<p>When trying to open an XML document, a parser-error may occur.</p>
<p>With the parseError object, you can retrieve the error code, the error text, the line that caused the error,
and more.
</p>
<p><b>Note:</b> The parseError object is not a part of the W3C DOM standard!</p>
<hr />
<h2>File Error
</h2>
<p>In the following code we will try to load a non-existing file, and
display some of its error properties:
</p>
<table border="1" width="100%" class="ex" cellspacing="0"><tr><td>
<pre>xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.load("ksdjf.xml");
document.write("Error code: " + xmlDoc.parseError.errorCode);
document.write("<br />Error reason: " + xmlDoc.parseError.reason);
document.write("<br />Error line: " + xmlDoc.parseError.line);</pre></td></tr></table>
<p><a target="_blank" href="tryit.asp@filename=note_error">Try it yourself</a></p>
<hr />
<h2>XML Error
</h2>
<p>In the following code we let the parser load an XML document that is not well-formed.
</p>
<p>(You can read more about well-formed and valid XML in our
<a href="../xml/default.asp">XML tutorial</a>)
</p>
<table border="1" width="100%" class="ex" cellspacing="0"><tr><td>
<pre>xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
xmlDoc.async="false";
xmlDoc.load("note_error.xml");
document.write("Error code: " + xmlDoc.parseError.errorCode);
document.write("<br />Error reason: " + xmlDoc.parseError.reason);
document.write("<br />Error line: " + xmlDoc.parseError.line);</pre></td></tr></table>
<p><a target="_blank" href="tryit.asp@filename=note_error_two">Try it yourself</a>
or just <a target="_blank" href="note_error.xml">look at the XML file</a></p>
<hr />
<h2>The parseError Object's Properties</h2>
<table border="1" width="100%" class="ex" cellspacing="0">
<tr>
<td width="25%"><b>Property</b></td>
<td width="75%"><b>Description</b></td>
</tr>
<tr>
<td>errorCode</td>
<td>Returns a long integer error code</td>
</tr>
<tr>
<td>reason</td>
<td>Returns a string containing the reason for the error</td>
</tr>
<tr>
<td>line</td>
<td>Returns a long integer representing the line number for the error</td>
</tr>
<tr>
<td>linepos</td>
<td>Returns a long integer representing the line position for the error</td>
</tr>
<tr>
<td>srcText</td>
<td>Returns a string containing the line that caused the error</td>
</tr>
<tr>
<td>url</td>
<td>Returns the URL pointing the loaded document</td>
</tr>
<tr>
<td>filepos</td>
<td>Returns a long integer file position of the error</td>
</tr>
</table>
<br />
<hr />
<a href="dom_http.asp"><img border="0" src="../images/btn_previous.gif" alt="prev" width="100" height="20" /></a>
<a href="dom_errors_crossbrowser.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 + -