nodeName, nodeValue and nodeType contain information about the node.
The nodeName attribute contains the name of a node.
The nodeName of the element node is the tag name
The nodeName of the attribute node is the attribute name
The nodeName of the text node is always #text
The nodeName of the document node is always #document
Note: The tag name of the XML element contained by nodeName is always uppercase
nodeValue
For text nodes, the nodeValue attribute contains the text.
For attribute nodes, the nodeValue attribute contains the attribute value.
The nodeValue attribute is not available for document nodes and element nodes.
nodeType The
nodeType attribute returns the type of node.
The most important node types are:
元素类型 | 节点类型 |
---|---|
元素element | 1 |
属性attr | 2 |
文本text | 3 |
注释comments | 8 |
文档document | 9 |