xml中element和node的区别
?
The Node object is the primary data type for the entire DOM.
A node can be an element node, an attribute node, a text node, or any other of the node types explained in the “Node types” chapter.
An XML element is everything from (including) the element’s start tag to (including) the element’s end tag.
From:?http://stackoverflow.com/questions/132564/whats-the-difference-between-an-element-and-a-node-in-xml
Element:
It is the main tag that can contain the data.
Node:
It is like a super type of an element
example:
<?xml version="1.0"?> <catalog> <book bookid="b001"> <bookname>ASP.NET</bookname> </book> </catalog>??
In this example:
Elements:
<catalog></catalog> <book></book> <bookname>ASP.NET</bookname>
Nodes:
all are nodes
<?xml version="1.0"?> <catalog>: elements are also nodes. <book bookid="b001"> <bookname>ASP.NET</bookname> </book> </catalog>
1)Processing Instruction:
<?xml version="1.0"?>
It is a node
2)all elements are nodes:
3) The attribute bookid is also a node.
4)data in the element (i.e. ASP.NET is also a Node)
XML DOM Node Types
NodeType Named Constant
1 ELEMENT_NODE
2 ATTRIBUTE_NODE
3 TEXT_NODE
4 CDATA_SECTION_NODE
5 ENTITY_REFERENCE_NODE
6 ENTITY_NODE
7 PROCESSING_INSTRUCTION_NODE
8 COMMENT_NODE
9 DOCUMENT_NODE
10 DOCUMENT_TYPE_NODE
11 DOCUMENT_FRAGMENT_NODE
12 NOTATION_NODE
Refer to?http://www.dotnetfunda.com/interview/exam3963-difference-between-an-element-and-node-in-xml.aspx