XML DOM node
In the DOM, every component in an XML document is a node.
DOM Nodes
According to the DOM, every component in an XML document is anode。
DOM specifies this:
- The entire document is a document node
- Every XML element is an element node.
- Text contained in an XML element is a text node.
- Every XML attribute is an attribute node.
- Annotations are annotation nodes.
DOM Examples
Please look at the following XML file (books.xml):
books.xml file code:
In the XML above, the root node is <bookstore>. All other nodes in the document are contained in <bookstore>.
The root node <bookstore> has four <book> nodes.
The first <book> node has four child nodes: <title>, <author>, <year>, and <price>. Each of these nodes contains a text node: "Everyday Italian", "Giada De Laurentiis", "2005", and "30.00".
Text is always stored in text nodes
A common error in DOM processing is to think that element nodes contain text.
However, the text of an element node is stored in a text node.
In this instance:<year>2005</year>The element node <year> has a text node with a value of "2005".
"2005" is notThe value of the <year> element!
other extensions