Skip to main content

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-only
  • nodeName of an element node is the same as the tag name
  • nodeName of an attribute node is the attribute name
  • nodeName of a text node is always #text
  • nodeName 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 undefined
  • nodeValue for text nodes is the text itself
  • nodeValue for attribute nodes is the attribute value

The nodeType Property

The nodeType property specifies the type of node.

note

nodeType is read only.

NodeTypeNamed Constant
1ELEMENT_NODE
2ATTRIBUTE_NODE
3TEXT_NODE
4CDATA_SECTION_NODE
5ENTITY_REFERENCE_NODE
6ENTITY_NODE
7PROCESSING_INSTRUCTION_NODE
8COMMENT_NODE
9DOCUMENT_NODE
10DOCUMENT_TYPE_NODE
11DOCUMENT_FRAGMENT_NODE
12NOTATION_NODE