Documentation

Traverser
in package

Traverser for walking a DOM tree.

This is a concrete traverser designed to convert a DOM tree into an HTML5 document. It is not intended to be a generic DOMTreeWalker implementation.

Tags
see
http://www.w3.org/TR/2012/CR-html5-20121217/syntax.html#serializing-html-fragments

Table of Contents

Properties

$dom  : mixed
$encode  : mixed
$local_ns  : mixed
Namespaces that should be treated as "local" to HTML5.
$options  : mixed
$out  : mixed
$rules  : mixed

Methods

__construct()  : mixed
Create a traverser.
children()  : mixed
Walk through all the nodes on a node list.
isLocalElement()  : bool
Is an element local?
node()  : mixed
Process a node in the DOM.
walk()  : resource
Tell the traverser to walk the DOM.

Properties

$local_ns

Namespaces that should be treated as "local" to HTML5.

protected static mixed $local_ns = array('http://www.w3.org/1999/xhtml' => 'html', 'http://www.w3.org/1998/Math/MathML' => 'math', 'http://www.w3.org/2000/svg' => 'svg')

Methods

__construct()

Create a traverser.

public __construct(DOMNode|DOMNodeList $dom, resource $out, RulesInterface $rules[, array<string|int, mixed> $options = array() ]) : mixed
Parameters
$dom : DOMNode|DOMNodeList

The document or node to traverse.

$out : resource

A stream that allows writing. The traverser will output into this stream.

$rules : RulesInterface
$options : array<string|int, mixed> = array()

An array of options for the traverser as key/value pairs. These include:

  • encode_entities: A bool to specify if full encding should happen for all named charachter references. Defaults to false which escapes &'<>".
  • output_rules: The path to the class handling the output rules.

children()

Walk through all the nodes on a node list.

public children(DOMNodeList $nl) : mixed
Parameters
$nl : DOMNodeList

A list of child elements to walk through.

isLocalElement()

Is an element local?

public isLocalElement(mixed $ele) : bool
Parameters
$ele : mixed

An element that implement \DOMNode.

Return values
bool

true if local and false otherwise.

node()

Process a node in the DOM.

public node(mixed $node) : mixed
Parameters
$node : mixed

A node implementing \DOMNode.

walk()

Tell the traverser to walk the DOM.

public walk() : resource
Return values
resource

$out Returns the output stream.


        
On this page

Search results