Prev |  | Next

## PHPTAL DOM

Internally PHPTAL represents documents using it's own document object model, a little bit similar to W3C's DOM. However, PHPTAL's API has only few basic methods for DOM manipulation.

`PHPTAL_Dom_Element` class has following properties and methods:

- `array childNodes ;`

  Numerically indexed array containing children of the element.

  #### Warning

  Please don't edit this array directly. Use `appendChild()`, etc.

  #### Note

  PHPTAL does not implement `nextSibling`, `firstChild`, etc.

- `PHPTAL_Dom_Element parentNode ;`

  Parent node (element) of the current element. Use it to traverse tree upwards.

- `void appendChild($node);`

  Appends node to the element. Node will be removed from its current element and added at the end of this element.

  #### Warning

  PHPTAL does not manage namespace declarations. Moving nodes between elements in different namespaces will change meaning of the document.

- `void replaceChild($new_node,
  $old_node);`

  Old node will be replaced with new node.

- `void removeChild($node);`

  Remove node from its parent.

- `string getAttributeNS($namespace_uri,
  $local_name);`

  Returns unescaped (without entities) value of a specific attribute.

      $a->getAttributeNS('','href')

  #### Tip

  In XML attributes don't inherit element's namespace, and all XHTML attributes are in the default namespace.

- `array getAttributeNodes();`

  Returns array of `PHPTAL_Dom_Attr` objects, which represent all element's attributes. You can modify attributes' values without using `setAttributeNodes()`.

- `void setAttributeNodes(array $attrs);`

  Replaces all elements attributes with the given ones.

- `string getLocalName();`

  Returns local name of the element, e.g. `<atom:title>` has local name `title`.

- `string getNamespaceURI();`

  Returns namespace URI of the the element, e.g. `<atom:title xmlns="http://www.w3.org/2005/Atom">` has namespace `http://www.w3.org/2005/Atom`.

  #### Tip

  XHTML namespace is `http://www.w3.org/1999/xhtml`.

Text, CDATA and attribute nodes have `getValueEscaped()` and `setValueEscaped()` methods which allow reading/setting of their text with entities preserved.

Prev | Up | Next
class `PHPTAL_PreFilter` | Home | interface `PHPTAL_Filter`