The DOM presents a document as a hierarchy of node objects.

Node Types

The following table lists the different W3C node types, and which node types they may have as children:

Node TypeDescriptionChildren
DocumentRepresents the entire document (the root-node of the DOM tree)Element (max. one), ProcessingInstruction, Comment, DocumentType
DocumentFragmentRepresents a “lightweight” Document object, which can hold a portion of a documentElement, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
DocumentTypeProvides an interface to the entities defined for the documentNone
ProcessingInstructionRepresents a processing instructionNone
EntityReferenceRepresents an entity referenceElement, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
ElementRepresents an elementElement, Text, Comment, ProcessingInstruction, CDATASection, EntityReference
AttrRepresents an attributeText, EntityReference
TextRepresents textual content in an element or attributeNone
CDATASectionRepresents a CDATA section in a document (text that will NOT be parsed by a parser)None
CommentRepresents a commentNone
EntityRepresents an entityElement, ProcessingInstruction, Comment, Text, CDATASection, EntityReference
NotationRepresents a notation declared in the DTDNone
SELECTED JUST FOR YOU
9 tips every Tech professional should know

Node Types – Return Values

The following table lists what the nodeName and the nodeValue properties will return for each node type:

Node TypenodeName returnsnodeValue returns
Document#documentnull
DocumentFragment#document fragmentnull
DocumentTypedoctype namenull
EntityReferenceentity reference namenull
Elementelement namenull
Attrattribute nameattribute value
ProcessingInstructiontargetcontent of node
Comment#commentcomment text
Text#textcontent of node
CDATASection#cdata-sectioncontent of node
Entityentity namenull
Notationnotation namenull
SELECTED JUST FOR YOU
How to hide text messages on your android phone

NodeTypes – Named Constants

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
Am a Software developer with a 3 year professional experience in several technologies not limited to PHP PYTHON and JavaScript, furthermore when am not coding or writing tech articles, you'll find me watching movies.

LEAVE A REPLY

Please enter your comment!
Please enter your name here