May 27, 2021 XML DOM
In DOM, each component of the XML document is a node.
The entire document is a document node, and each XML tag is an element node.
According to the DOM, each component of the XML document is a node.
The DOM states as this:
Take a look at the XML file below (.xml):
<?xml version="1.0" encoding="ISO-8859-1"?>
<bookstore>
<book category="cooking">
<title lang="en">Everyday Italian</title>
<author>Giada De Laurentiis</author>
<year>2005</year>
<price>30.00</price>
</book>
<book category="children">
<title lang="en">Harry Potter</title>
<author>J K. Rowling</author>
<year>2005</year>
<price>29.99</price>
</book>
<book category="web">
<title lang="en">XQuery Kick Start</title>
<author>James McGovern</author>
<author>Per Bothner</author>
<author>Kurt Cagle</author>
<author>James Linn</author>
<author>Vaidyanathan Nagarajan</author>
<year>2003</year>
<price>49.99</price>
</book>
<book category="web" cover="paperback">
<title lang="en">Learning XML</title>
<author>Erik T. Ray</author>
<year>2003</year>
<price>39.95</price>
</book>
</bookstore>
In the XML above, the root node is the .lt;bookstore. All other nodes in the document are included in the .
The root node, the bookstore, has four nodes, the lt;book, and the node.
The first node has four nodes: "Italian Everyday," "Giada De Laurentiis," "2005," and "30.00."
A common mistake in DOM processing is to think that element nodes contain text.
However, the text of the element node is stored in the text node.
In this example: .lt;year.gt;2005</year>, element node slt;year>, has a text node with a value of "2005".
"2005" is not the value of the element!
This section describes the knowledge of XML DOM nodes, and in the next section you will learn about the XML DOM node tree.