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.
![Illustration of a simple HTML document represented in a hierarchy containing element nodes for two texts: Sample Page and Hello world!](https://static.packt-cdn.com/products/9781119366447/graphics/images/c14f001.png)
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...