📄 dom_nodetree.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 Tree</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 Tree</h1>
<a href="dom_nodes.asp"><img border="0" src="../images/btn_previous.gif" alt="prev" width="100" height="20" /></a>
<a href="dom_parser.asp"><img border="0" src="../images/btn_next.gif" alt="next" width="100" height="20" /></a>
<hr />
<p class="intro">The XML DOM views an XML document as a node-tree.</p>
<p class="intro">All the nodes in the tree have a relationship to each other.</p>
<hr />
<h2>The XML DOM Node Tree</h2>
<p>The XML DOM views an XML document as a tree-structure. The tree structure is
called a <b>node-tree.</b></p>
<p>All nodes
can be accessed through the tree. Their contents can be
modified or deleted, and new elements can be created.</p>
<p>The node tree shows the set of nodes, and the connections
between them. The tree starts at
the root node and branches out to the
text nodes at the lowest level of the tree:</p>
<p>
<img border="0" src="nodetree.gif" alt="DOM node tree" width="486" height="275" /></p>
<p>The image above represents the XML file <a target="_blank" href="books.xml">books.xml</a>.</p>
<hr />
<h2>Node Parents, Children, and Siblings</h2>
<p>The nodes in the node tree have a hierarchical relationship to each other.</p>
<p>The terms parent, child, and sibling are used to describe
the relationships. Parent nodes have
children. Children on the same level are called siblings
(brothers or sisters).
</p>
<ul>
<li>In a node tree, the top node is called the root</li>
<li>Every node, except
the root, has exactly one
parent node</li>
<li>A node can have any
number of children</li>
<li>A leaf is a node with no children</li>
<li>Siblings are nodes with the same parent</li>
</ul>
<p>The following image illustrates a part of the node tree and the
relationship between the nodes:</p>
<p><img border="0" src="navigate.gif" alt="Node tree" width="335" height="354" /></p>
<p>Because the XML data is structured in a tree form, it can be traversed without
knowing the exact structure of the tree
and without knowing the type of data contained within. </p>
<p>You will learn more about traversing the node tree in a later chapter of this
tutorial.</p>
<hr />
<h2>First Child - Last Child</h2>
<p>Look at the following XML fragment:</p>
<table border="1" width="100%" class="ex" cellspacing="0" id="table1">
<tr>
<td valign="top">
<pre><bookstore>
<book category="cooking">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
</bookstore></pre>
</td>
</tr>
</table>
<p>In the XML above, the <title> element is the first child of the <book>
element, and the <price> element is the last child of the <book> element.</p>
<p>Furthermore, the <book> element is the parent node of the <title>,
<author>, <year>, and <price> elements.</p>
<hr />
<a href="dom_nodes.asp"><img border="0" src="../images/btn_previous.gif" alt="prev" width="100" height="20" /></a>
<a href="dom_parser.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 + -