Node (W3C DOM Core object)
| Version | Depr. |
|---|---|
| DOM1 | No |
| IE5.5+ | FF1.5+ | SA1.3+ | OP9+ |
|---|---|---|---|
| Partial | Full | Buggy | Full |
Description
The Node
interface is the primary data type for the Document Object Model (DOM). It
represents any single item in the tree, such as an
Element, Attr, Document or Entity.
Whether a
Node may have children depends on its type.
The
following table is an overview of each of the core interfaces, showing how
the nodeName and nodeType returns, and what kind of children the node is
allowed to have.
| Interface | nodeName |
nodeType |
Children |
|---|---|---|---|
Element |
The tag name, eg. HTML |
1 |
Element, Text,
Comment, ProcessingInstruction, CDATASection, EntityReference |
Attr |
The attribute name, eg. id |
2 |
Text, EntityReference 1 |
Text |
#text |
3 |
Cannot have children |
CDATASection |
#cdata-section |
4 |
Cannot have children |
EntityReference |
The name of the entity reference, eg.
amp |
5 |
Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference |
Entity |
The entity name, eg. & |
6 |
Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference |
ProcessingInstruction |
The target of the processing instruction, eg.
xml-stylesheet |
7 |
Cannot have children |
Comment |
#comment |
8 |
Cannot have children |
Document |
#document |
9 |
Element (one only), ProcessingInstruction, Comment, DocumentType (one
only) |
DocumentType |
The name of the document type, eg.
html |
10 |
Cannot have children |
DocumentFragment |
#document-fragment |
11 |
Element, ProcessingInstruction, Comment, Text, CDATASection, EntityReference |
Notation |
The notation name | 12 |
Cannot have children |
Compatibility
| Internet Explorer | Firefox | Safari | Opera | |||||||
|---|---|---|---|---|---|---|---|---|---|---|
| 5.5 | 6.0 | 7.0 | 1.5 | 2.0 | 3.0 | 1.3 | 2.0 | 3.0 | 9.0 | 9.5 |
| Partial | Partial | Partial | Full | Full | Full | Buggy | Buggy | Buggy | Full | Full |
Internet Explorer doesn't implement the following:
Additionally, Internet Explorer 5.5 doesn't implement the following:
Internet Explorer has additional
features in its implementation of childNodes and
attributes.
Safari has
bugs in its implementation of childNodes.
Safari 1.3 and
2 have bugs in their implementation of localName.
Opera has
additional features in its implementation of childNodes.
All
browsers have bugs in their implementation of attributes.
In this Section
- appendChild
Add a new node and its subtree to the end of the list of children of this node. - attributes
An unordered list of all the effective attributes that apply to an element. - childNodes
An ordered list of all the child nodes of this node. - cloneNode
Create a duplicate of this node, including all attributes and their values. - firstChild
The first node that is a direct child of this node. - hasAttributes
Whether an element has any attributes. - hasChildNodes
Returns whether this node has any child nodes. - insertBefore
Insert a new node as a child of this node, directly before an existing child of this node. - isSupported
Whether a specific feature of the DOM is implemented, and supported by this node. - lastChild
The last node that is a direct child of this node. - localName
The name of an element or attribute, not including any namespace prefix. - namespaceURI
The namespace URI of an element or attribute node. - nextSibling
The node immediately after this node. - nodeName
The name of this node, according to its type. - nodeType
A numeric code that represents the type of this node. - nodeValue
The value if this node, if it has one. - normalize
Puts this node's sub-tree in a state whereby only structural nodes separate text nodes. - ownerDocument
The document which contains this node. - parentNode
The parent of this node. - prefix
The namespace prefix of this node. - previousSibling
The node immediately before this node. - removeChild
Removes a specified node from the children of this node. - replaceChild
Replace an existing child of this node with a new child node.
User-contributed notes
There are no comments yet.
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.