AnewtXMLDomNode class

Base node class.

Class Overview

Base node class.

AnewtXMLDomNode instances cannot be instantiated directly, since this class only serve as a base class for e.g. AnewtXMLDomElement and AnewtXMLDomText.

Todo

: Implement first_child, last_child, previous_sibling and next_sibling attributes in node trees.

Public Static Methods

static create_for_value($value) [static]

Create a new DOM node for any value.

This method converts any value into a AnewtXMLDomNode instance (or subclass thereof). If the value is a renderer object, it is rendered. If the renderer object renders an AnewtXMLDomNode itself, it is used, else the rendered value is converted to a text node (which takes care of escaping).

Parameters

$value

The value to convert

Return value

An AnewtXMLDomNode instance (or subclass).

Public Methods

__construct()

Construct and initialise a new node instance.

is_same_node($other_node)

Returns whether this node is the same node as the given one.

Parameters

$other_node

A AnewtXMLDomNode instance to test against.

Return value

Returns true if the nodes are the same, false otherwise.

See also

append_child($new_child)

Adds the node $new_child to the end of the list of children of this node.

The node may not be attached elsewhere in the tree already.

Parameters

$new_child

The node to add.

Return value

The node added.

See also

append_children(&$new_children)

Recursively appends children to this element.

Strings are converted into text nodes. This method expands numerical arrays and ignores null values.

Parameters

$new_children

Array of children elements

& remove_child(&$old_child)

Removes the child node from the list of children, and returns it.

Parameters

$old_child

The node being removed.

Return value

The node removed.

See also

& replace_child(&$new_child, &$old_child)

Replaces a child node with a new child, and returns the old child node.

Todo

This method is not implemented yet.

Parameters

$new_child

The new node to put in the child list.

$old_child

The node being replaced in the list.

Return value

The node replaced.

See also

& insert_before(&$new_child, &$ref_child)

Inserts the node $new_child before the existing child node $ref_child.

If $ref_child is null, insert $new_child at the end of the list of children.

Todo

This method is not implemented yet.

Parameters

$new_child

The node to insert.

$ref_child

The reference node, i.e., the node before which the new node must be inserted.

Return value

The node being inserted.

See also

has_child_nodes()

Returns whether this node has any children.

Return value

Returns true if this node has any children, false otherwise.

See also

Public Attributes

$node_name

The name of this node, depending on its type.

Protected Attributes

$allowed_attributes [protected]

List of allowed attributes.

$must_be_empty [protected]

Whether this node can contain children.

$allowed_elements [protected]

List of allowed child element names.

$allows_text [protected]

Whether this node can have text content.

Private Attributes

$__object_id [private]

Used for identity checking.