Xml dom Node

Source: Internet
Author: User
Tags xml attribute

From: w3cschool cainiao tutorial

In the DOM, each component in the XML document is a node.


DOM Node


According to the DOM, each component in the XML document is a node.

DOM is as follows:

  • The entire document is a document Node

  • Each XML element is an element node.

  • The text contained in the XML element is a text node.

  • Each XML Attribute is a property node.

  • Annotation is a comment node.

DOM instance

See the following XML file books. xml). The Code is as follows:


<?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 preceding XML, the root node is <bookstore>. All other nodes in this document are included in <bookstore>.



The root node <bookstore> has four <book> nodes.

The first <book> node has four nodes: <title>, <author>, <year>, and <price>. Each node 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 that an element node contains text.

However, the text of the element node is stored in the text node.

In this example: <year> 2005 </year>, the element node <year> has a text node with a value of "2005.

"2005" is not the value of the <year> element!


Reprinted Please note: http://www.w3cschool.cc/dom/dom-nodes.html


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.