Node
(W3C DOM Core object)
Version | Depr. |
---|---|
DOM1 | NO |
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 thenodeName
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 |
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.
Element
(W3C DOM Core object)
Description
The Element
interface inherits from Node
, and represents a single element in an HTML or XML document.
An Element
node may have other Element
, Text
, Comment
, ProcessingInstruction
,CDATASection
or EntityReference
nodes as children.
In this Section
- getAttribute
Get the value of an attribute with the specified name. - getAttributeNode
Get an attribute node with the specified name. - getAttributeNodeNS
Get the value of an attribute with the specified name and namespace URI. - getAttributeNS
Get the value of an attribute with the specified name and namespace URI. - getElementsByTagName
Retrieves an ordered list of all elements with a given tag name, that are descendants of this document or element, in the linear order in which they appear in the DOM tree. - getElementsByTagNameNS
Retrieves an ordered list of all elements with a given localName and namespaceURI, that are descendants of this document or element, in the linear order in which they appear in the DOM tree. - hasAttribute
Whether this element has an attribute with the specified name, or has a specific default value for that attribute in this document type. - hasAttributeNS
Whether this element has an attribute with the specified local name and namespace URI, or has a specific default value for that attribute in this document type. - removeAttribute
Remove an attribute with the specified name. - removeAttributeNode
Remove a specified attribute node. - removeAttributeNS
Remove an attribute with the specified name and namespace URI. - setAttribute
Set a new attribute on this element, with the specified name and value. - setAttributeNode
Add an attribute node to this element. - setAttributeNodeNS
Add a namespaced attribute node to this element. - setAttributeNS
Set a new attribute on this element, with the specified local name, namespace URI and value. - tagName
The qualified name of an element (including any namespace prefix).