📄 dom_nodetype.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 - Node Types</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 Node Types</h1>
<a href="dom_httprequest.asp"><img border="0" src="../images/btn_previous.gif" alt="prev" width="100" height="20" /></a>
<a href="dom_node.asp"><img border="0" src="../images/btn_next.gif" alt="next" width="100" height="20" /></a>
<hr />
<p class="intro">The DOM presents a document as a hierarchy of node objects.</p>
<hr />
<h2>Examples</h2>
<p>The examples below use the XML file
<a target="_blank" href="books.xml">books.xml</a>. <br />
A function, <a href="dom_loadxmldoc.asp">loadXMLDoc()</a>, in an external JavaScript is used to load the XML file.</p>
<p><a target="_blank" href="tryit.asp@filename=try_dom_nodetype">Display nodeName and nodeType of all elements</a></p>
<p><a target="_blank" href="tryit.asp@filename=try_dom_nodevalue">Display nodeName and nodeValue of all elements</a></p>
<hr />
<h2>Node Types</h2>
<p>The following table lists the different W3C node types, and which node types they
may have as children:</p>
<table border="1" width="100%" class="ex" cellspacing="0" id="table1">
<tr>
<th width="28%" align="left" valign="top">Node type</th>
<th width="40%" align="left" valign="top">Description</th>
<th width="32%" align="left" valign="top">Children</th>
</tr>
<tr>
<td valign="top">Document</td>
<td valign="top">Represents the entire document (the root-node of the DOM tree)</td>
<td valign="top">Element (max. one), ProcessingInstruction, Comment, DocumentType</td>
</tr>
<tr>
<td valign="top">DocumentFragment</td>
<td valign="top">Represents a "lightweight" Document object, which
can hold a portion of a document</td>
<td valign="top">Element, ProcessingInstruction, Comment, Text, CDATASection,
EntityReference</td>
</tr>
<tr>
<td valign="top">DocumentType</td>
<td valign="top">Provides an interface to the entities defined for the
document</td>
<td valign="top">None</td>
</tr>
<tr>
<td valign="top">ProcessingInstruction</td>
<td valign="top">Represents a processing instruction</td>
<td valign="top">None</td>
</tr>
<tr>
<td valign="top">EntityReference</td>
<td valign="top">Represents an entity reference</td>
<td valign="top">Element, ProcessingInstruction, Comment, Text, CDATASection,
EntityReference</td>
</tr>
<tr>
<td valign="top">Element</td>
<td valign="top">Represents an element</td>
<td valign="top">Element, Text, Comment, ProcessingInstruction, CDATASection,
EntityReference</td>
</tr>
<tr>
<td valign="top">Attr</td>
<td valign="top">Represents an attribute</td>
<td valign="top">Text, EntityReference</td>
</tr>
<tr>
<td valign="top">Text</td>
<td valign="top">Represents textual content in an element
or attribute</td>
<td valign="top">None</td>
</tr>
<tr>
<td valign="top">CDATASection</td>
<td valign="top">Represents a CDATA section in a document (text that will
NOT be parsed by a parser)</td>
<td valign="top">None</td>
</tr>
<tr>
<td valign="top">Comment</td>
<td valign="top">Represents a comment</td>
<td valign="top">None</td>
</tr>
<tr>
<td valign="top">Entity</td>
<td valign="top">Represents an entity</td>
<td valign="top">Element, ProcessingInstruction, Comment, Text, CDATASection,
EntityReference</td>
</tr>
<tr>
<td valign="top">Notation</td>
<td valign="top">Represents a notation declared in the DTD</td>
<td valign="top">None</td>
</tr>
</table>
<br />
<hr />
<h2>Node Types - Return Values</h2>
<p>The following table lists what the nodeName and the nodeValue properties will return
for each node type:</p>
<table border="1" width="100%" class="ex" cellspacing="0" id="table2">
<tr>
<th width="30%" align="left" valign="top">Node type</th>
<th width="40%" align="left" valign="top">nodeName returns</th>
<th width="30%" align="left" valign="top">nodeValue returns</th>
</tr>
<tr>
<td valign="top">Document</td>
<td valign="top">#document</td>
<td valign="top">null</td>
</tr>
<tr>
<td valign="top">DocumentFragment</td>
<td valign="top">#document fragment</td>
<td valign="top">null</td>
</tr>
<tr>
<td valign="top">DocumentType</td>
<td valign="top">doctype name</td>
<td valign="top">null</td>
</tr>
<tr>
<td valign="top">EntityReference</td>
<td valign="top">entity reference name</td>
<td valign="top">null</td>
</tr>
<tr>
<td valign="top">Element</td>
<td valign="top">element name</td>
<td valign="top">null</td>
</tr>
<tr>
<td valign="top">Attr</td>
<td valign="top">attribute name</td>
<td valign="top">attribute value</td>
</tr>
<tr>
<td valign="top">ProcessingInstruction</td>
<td valign="top">target</td>
<td valign="top">content of node</td>
</tr>
<tr>
<td valign="top">Comment</td>
<td valign="top">#comment</td>
<td valign="top">comment text</td>
</tr>
<tr>
<td valign="top">Text</td>
<td valign="top">#text</td>
<td valign="top">content of node</td>
</tr>
<tr>
<td valign="top">CDATASection</td>
<td valign="top">#cdata-section</td>
<td valign="top">content of node</td>
</tr>
<tr>
<td valign="top">Entity</td>
<td valign="top">entity name</td>
<td valign="top">null</td>
</tr>
<tr>
<td valign="top">Notation</td>
<td valign="top">notation name</td>
<td valign="top">null</td>
</tr>
</table>
<br />
<hr />
<h2>NodeTypes - Named Constants</h2>
<table border="1" width="100%" class="ex" cellspacing="0">
<tr>
<th width="15%" align="left" valign="top">NodeType</th>
<th width="85%" align="left" valign="top">Named Constant</th>
</tr>
<tr>
<td valign="top">1</td>
<td valign="top">ELEMENT_NODE</td>
</tr>
<tr>
<td valign="top">2</td>
<td valign="top">ATTRIBUTE_NODE</td>
</tr>
<tr>
<td valign="top">3</td>
<td valign="top">TEXT_NODE</td>
</tr>
<tr>
<td valign="top">4</td>
<td valign="top">CDATA_SECTION_NODE</td>
</tr>
<tr>
<td valign="top">5</td>
<td valign="top">ENTITY_REFERENCE_NODE</td>
</tr>
<tr>
<td valign="top">6</td>
<td valign="top">ENTITY_NODE</td>
</tr>
<tr>
<td valign="top">7</td>
<td valign="top">PROCESSING_INSTRUCTION_NODE</td>
</tr>
<tr>
<td valign="top">8</td>
<td valign="top">COMMENT_NODE</td>
</tr>
<tr>
<td valign="top">9</td>
<td valign="top">DOCUMENT_NODE</td>
</tr>
<tr>
<td valign="top">10</td>
<td valign="top">DOCUMENT_TYPE_NODE</td>
</tr>
<tr>
<td valign="top">11</td>
<td valign="top">DOCUMENT_FRAGMENT_NODE</td>
</tr>
<tr>
<td valign="top">12</td>
<td valign="top">NOTATION_NODE</td>
</tr>
</table>
<br />
<hr />
<a href="dom_httprequest.asp"><img border="0" src="../images/btn_previous.gif" alt="prev" width="100" height="20" /></a>
<a href="dom_node.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 + -