DOM node type
XML DOM Node type
DOM is a document that represents a hierarchy of node objects.
Try it out - Example
The example below uses the XML file books.xml.
Function loadXMLDoc(), located in external JavaScript, is used to load XML files.
Display the nodeName and nodeType of all elements
Display the nodeName and nodeValue of all elements
Node type
The following table lists the different W3C node types, each node type may contain subclasses:
##EntityRepresents an entityElement, ProcessingInstruction, Comment, Text, CDATASection, EntityReferenceNotationDefine a symbol declared in the DTDNoneNode type - return value
The following table lists the node name (nodeName) and node value (nodeValue) returned by each node type (nodetype):
Node type | Description | Subclass |
---|---|---|
Document | Represents the entire document (the root node of the DOM tree) | Element (max. one), ProcessingInstruction, Comment, DocumentType |
DocumentFragment | Represents a "lightweight" Document object, which can retain a part of the document | Element, ProcessingInstruction, Comment, Text, CDATASection, Entity Reference Manual |
DocumentType | Provides an interface for entities defined in documents | None |
ProcessingInstruction | Represents a processing instruction | None |
EntityReference | Represents an entity reference | Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference |
Element | represents an element | Element, Text, Comment, ProcessingInstruction, CDATASection, EntityReference |
Attr | represents an attribute | Text, EntityReference |
Text | Represents the text content of the element or attribute | None |
CDATASection | Represents the CDATA section in the document (the text will not be parsed by the parser) | None |
Comment | represents a comment | None |
Node type | Returned node name | Returned node value |
---|---|---|
Document | #document | null |
DocumentFragment | #document fragment | null |
DocumentType | Document type name | null |
Entity Reference Manual | Entity reference name | null |
Element | Element name | null |
ENTITY_NODE | |
PROCESSING_INSTRUCTION_NODE | |
COMMENT_NODE | |
DOCUMENT_NODE | |
DOCUMENT_TYPE_NODE | |