The Node Structure

DOM provides an interface to navigate and manipulate the hierarchical structure of markup. Most DOM objects are nodes, providing generalized means of navigating from one node to another, changing the children of the node, and other ways of using and modifying the structure of the content.

Attributes

attributes node

The attributes attribute provides a named node map containing the attributes of the node if it is an element, and NIL otherwise.

Child Nodes

child-nodes node

The child-nodes attribute provides a nodelist of all childrens of the node.

First Child

first-child node

The first-child attribute provides the first child of the node, or NIL if there are no children.

Last Child

last-child node

The last-child attribute provides the last child of the node, or NIL if there are no children.

Local Name

local-name node

The local-name attributes returns the local part of the qualified name of the node as a string. The string is unique for the namespace of the node.

Namespace URI

namespace-uri node

The namespace uri of this node.

Normalize

normalize node

Concatenates adjacent Text nodes and remove empty ones.

Previous Sibling

previous-sibling node

The previous-sibling attribute provides the node immediately preceeding the node, or NIL if there are no such node. This can for example be used to get the element preceeding a given element.

Next Sibling

next-sibling node

The next-sibling attribute provides the node immediately following this node, or NIL if there is no such node. This can be used for example to find the element that follows a given element.

Node Name

node-name node

The node-name attribute provides the name of the node. The name depends on the type of node, as listed in the DOM specification. Typically, the name is available using a more specialized function than node-name.

Node Value

node-value node
set-node-value node value

The node-value attribute provides the value of the node. The value depends on the type of the node, as specified in the DOM standard. In most cases, a more specialized function than node-value is used to get the value of a node.

Node Type

node-type node

The node-type attribute indicates the type of node, matching one of the following constants:

element-node
The node is an element.
attribute-node
The node is an attribute.
text-node
The node is a text.
cdata-section-node
The node is a CDATA section.
entity-reference-node
The node is an entity reference.
entity-node
The node is an entity.
processing-instruction-node
The node is a processing instruction.
comment-node
The node is a comment.
document-node
The node is a document
document-type-node
The node is a document type declaration.
document-fragment-node
The node is a document fragment.
notation-node
The node is a notation.

Parent Node

parent-node node

The parent-node attribute refers to the parent of the node. This allow navigation from one node to the node that it belongs to. For example, a script can do something with the element that contains a specific element, such as identifying its name:

(dom:with-open-dom (homepage "home:documents;index.html")
 (let ((title-element (dom:item (dom:get-elements-by-tag-name homepage "TITLE") 0)))
  (dom:node-name (dom:parent-node title-element))))

; If the homepage document in the example above is correct, the form should result in the value "HEAD", as this is the name of the container of a correctly placed TITLE element.

Append Child

append-child node new-child

The append-child method adds a node to the end of the list of children of the current node, and returns the added node. If the new child is already in the list of children, it is first removed. If the new node is a document fragment, the entire contents are moved into the child list of this node. The method takes two arguments: the current node, and the node to append.

Insert Before

insert-before node new-child ref-child

The insert-before method inserts a node before a specific child node. The method takes three arguments: The current node, the node to insert, and the optional node before which the new node must be inserted. The method returns the node being inserted.

Owner Document

owner-document node

The document object associated with this node.

Prefix

prefix node

The namespace prefix of this node, or null if it is unspecified.

Replace Child

replace-child node new-child old-child

The replace-child method replaces a specific child node with a new node in the list of children, and returns the replaced node. It takes three arguments: The current node, the new node to put in the child list, and the node being replaced in the list.

Remove Child

remove-child node old-child

The remove-child method removes a specified child node from the list of children, and returns the removed node. It takes two arguments: The current node, and the node being removed.

Supports

supports node feature version

Tests whether the node implements a specific feature.

Has Child Nodes

has-child-nodes node

The has-child-nodes method allow easy determination of whether a node has any children. It returns a true value if the node has children, NIL otherwise. The method takes one argument: The current node.

Clone Node

clone-node node deep

The clone-node method returns a duplicate of a node, except that the clone has no parent. The method takes two arguments: A node to clone, and an optional boolean that indicates whether to recursively clone the children of the node.


This site is enhanced with Interaction.