XML DOM Node Information
The nodeName, nodeValue, and nodeType properties contain information about nodes.
Node Properties
note
Remember: in XML DOM, each node is an object.
Objects have methods and properties, that can be accessed and manipulated by JavaScript.
Three important node properties are:
nodeNamenodeValuenodeType
The nodeName Property
The nodeName property specifies the name of a node.
More in detail:
nodeNameis read-onlynodeNameof an element node is the same as the tag namenodeNameof an attribute node is the attribute namenodeNameof a text node is always #textnodeNameof the document node is always #document
The nodeValue Property
The nodeValue property specifies the value of a node.
More in detail:
nodeValuefor element nodes is undefinednodeValuefor text nodes is the text itselfnodeValuefor attribute nodes is the attribute value
The nodeType Property
The nodeType property specifies the type of node.
note
nodeType is read only.
| 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 |