XML DOM Node Types (Node Types)
- Previous Page DOM Manual Directory
- Next Page DOM Attr
Example
In the following example, we will use the XML file books.xmlas well as the JavaScript function loadXMLDoc().
Node type
The following table lists different W3C node types and their possible child elements:
Node type | Description | Child elements |
---|---|---|
Document | Represents the entire document (the root node of the DOM tree) |
|
DocumentFragment | Represents a lightweight Document object that contains part of the document. |
|
DocumentType | Provides an interface to the entity defined for the document. | None |
ProcessingInstruction | Represents a processing instruction. | None |
EntityReference | Represents an entity reference element. |
|
Element | Represents an element (element) element |
|
Attr | Represents an attribute. |
|
Text | Represents the text content within an element or attribute. | None |
CDATASection | Represents a CDATA section in the document (the text is not parsed by the parser). | None |
Comment | Represents a comment. | None |
Entity | Represents an entity. |
|
Notation | Represents a symbol declared in DTD. | None |
Node type - The returned value
The following table lists the values that the nodeName and nodeValue properties can return for each node type:
Node type | The return value of nodeName | The return value of nodeValue |
---|---|---|
Document | #document | null |
DocumentFragment | #document fragment | null |
DocumentType | doctype name | null |
EntityReference | Entity Reference Name | null |
Element | element name | null |
Attr | Attribute Name | Attribute Value |
ProcessingInstruction | target | The content of the node |
Comment | #comment | Comment Text |
Text | #text | Node Content |
CDATASection | #cdata-section | Node Content |
Entity | Entity Name | null |
Notation | Symbol Name | null |
NodeTypes - Named Constants
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 |
- Previous Page DOM Manual Directory
- Next Page DOM Attr