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:
nodeName
nodeValue
nodeType
The nodeName Property
The nodeName
property specifies the name of a node.
More in detail:
nodeName
is read-onlynodeName
of an element node is the same as the tag namenodeName
of an attribute node is the attribute namenodeName
of a text node is always #textnodeName
of the document node is always #document
The nodeValue Property
The nodeValue
property specifies the value of a node.
More in detail:
nodeValue
for element nodes is undefinednodeValue
for text nodes is the text itselfnodeValue
for 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 |