I am confused about Element and Node because I don't understand the entire structure of xml. Here is a brief overview:
The following figure is the xml document tree diagram of the w3c.org website:
As can be seen from the above figure, an XML document consists of element nodes, attribute nodes, and text nodes. The bookstore is called the document element or root element, and is also an element node
This is how XML DOM specifies a node
Each component in an XML document is a node.
The entire document is a document node, namely the Document node. In Java, Document interface is inherited from the Node interface, representing 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, Text interface inherits from the CharacterData interface, while CharacterData inherits from the Node interface, representing the text content of Element or Attr
Each XML attribute is an attribute node, namely the Attr node. In Java, Attr interface inherits from Node interface.
Comments belong to comment nodes, namely Comment nodes. In java, Comment interface inherits from the CharacterData interface, while CharacterData inherits from the Node interface
So in fact, every object in the XML document is a node. An element must be a node, and a node does not necessarily be an element.
The above article on Java parsing XML Node and Element (recommended) is all the content I share with you. I hope you can give you a reference and I hope you can support Wulin.com more.