Java parses the differences between XML Node and Element (recommended), nodeelement

Source: Internet
Author: User
Tags xml attribute

Java parses the differences between XML Node and Element (recommended), nodeelement

Element and Node are confused because they do not understand the entire xml structure. The following is a brief overview:

Think of the xml document tree of w3c.org:

It can be seen that an xml document consists of element nodes, attribute nodes, and text nodes. bookstore is called a document element or root element and is also an element node.

Xml dom specifies a node in this way.

Each component in the XML document is a node.

The entire Document is a Document node. In java, the Document interface is inherited from the Node interface, indicating the entire XML Document

Each XML tag is an ELEMENT node, that is, an ELEMENT node. In Java, the Element interface inherits from the Node interface to represent an Element in the XML document.

The Text contained in the XML element is a Text node, that is, a Text node. In java, the Text interface inherits from the CharacterData interface, while CharacterData inherits from the Node interface, indicating the Text content of Element or Attr.

Each XML Attribute is an attribute node, that is, an Attr node. In java, the Attr interface inherits from the Node interface.

A Comment is a Comment node. In java, the Comment interface inherits from the CharacterData interface, while CharacterData inherits from the Node interface.

In fact, every object in the xml document is a node. The element must be a node, but the node may not be an element.

The difference between the above java parsing XML Node and Element (recommended) is all the content shared by the editor. I hope to give you a reference, and I hope you can provide more support to the customer's house.

Related Article

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.