The Node interface is the primary datatype for the entire
Document Object Model. It represents a single node in the document tree.
While all objects implementing the Node interface expose
methods for dealing with children, not all objects implementing the
Node interface may have children. For example,
Text nodes may not have children, and adding children to
such nodes results in a DOMException being raised.
The attributes nodeName, nodeValue and
attributes are included as a mechanism to get at node
information without casting down to the specific derived interface. In
cases where there is no obvious mapping of these attributes for a
specific nodeType (e.g., nodeValue for an
Element or attributes for a Comment
), this returns null. Note that the specialized interfaces
may contain additional and more convenient mechanisms to get and set the
relevant information.
The values of nodeName,
nodeValue, and attributes vary according to the
node type as follows:
Interface
nodeName
nodeValue
attributes
Attr
same as Attr.name
same as
Attr.value
null
CDATASection
"#cdata-section"
same as CharacterData.data, the
content of the CDATA Section
null
Comment
"#comment"
same as CharacterData.data, the
content of the comment
null
Document
"#document"
null
null
DocumentFragment
"#document-fragment"
null
null
DocumentType
same as
DocumentType.name
null
null
Element
same as Element.tagName
null
NamedNodeMap
Entity
entity name
null
null
EntityReference
name of entity referenced
null
null
Notation
notation name
null
null
ProcessingInstruction
same
as ProcessingInstruction.target
same as
ProcessingInstruction.data
null
Text
"#text"
same as CharacterData.data, the content
of the text node
Nodeinterface is the primary datatype for the entire Document Object Model. It represents a single node in the document tree. While all objects implementing theNodeinterface expose methods for dealing with children, not all objects implementing theNodeinterface may have children. For example,Textnodes may not have children, and adding children to such nodes results in aDOMExceptionbeing raised.The attributes
nodeName,nodeValueandattributesare included as a mechanism to get at node information without casting down to the specific derived interface. In cases where there is no obvious mapping of these attributes for a specificnodeType(e.g.,nodeValuefor anElementorattributesfor aComment), this returnsnull. Note that the specialized interfaces may contain additional and more convenient mechanisms to get and set the relevant information.The values of
nodeName,nodeValue, andattributesvary according to the node type as follows:AttrAttr.nameAttr.valuenullCDATASection"#cdata-section"CharacterData.data, the content of the CDATA SectionnullComment"#comment"CharacterData.data, the content of the commentnullDocument"#document"nullnullDocumentFragment"#document-fragment"nullnullDocumentTypeDocumentType.namenullnullElementElement.tagNamenullNamedNodeMapEntitynullnullEntityReferencenullnullNotationnullnullProcessingInstructionProcessingInstruction.targetProcessingInstruction.datanullText"#text"CharacterData.data, the content of the text nodenullSee also the Document Object Model (DOM) Level 3 Core Specification.