HIERARCHY OF NODES
Any HTML or XML document can be represented as a hierarchy of nodes using the DOM. There are several node types, each representing different information and/or markup in the document. Each node type has different characteristics, data, and methods, and each may have relationships with other nodes. These relationships create a hierarchy that allows markup to be represented as a tree, rooted at a particular node. For instance, consider the following HTML:
<html>
<head>
<title>Sample Page</title>
</head>
<body>
<p>Hello World!</p>
</body>
</html>
This simple HTML document can be represented in a hierarchy, as illustrated in Figure 14-1.
A document node represents every document as the root. In this example, the only child of the document node is the <html>
element, which is called the document element. The document element is the outermost element in the document within which all...