function dump_tree(tidy_node $node, $indent = 0) { /* Put something there if the node name is empty */ $nodename = trim(strtoupper($node->name)); $nodename = empty($nodename) ? "[EMPTY]" : $nodename; /* Generate the Node, and a pretty name for it */ do_leaf(" + {$nodename} (" . node_type($node->type) . ")\n", $indent); /* Check to see if this node is a text node. Text nodes are generated by start/end tags and contain the text in between. i.e. <B>foo</B> will create a text node with $node->value equal to 'foo' */ if ($node->type == TIDY_NODETYPE_TEXT) { do_leaf(" |\n", $indent); do_leaf(" +---- Value: '{$node->value}'\n", $indent); } if (count($node->attribute)) { do_leaf(" |\n", $indent); do_leaf(" +---- Attributes\n", $indent); foreach ($node->attribute as $name => $value) { @do_leaf(" +-- {$name}\n", $indent); do_leaf(" | +-- Value: {$value}\n", $indent); } } /* Recurse along the children to generate the remaining nodes */ if ($node->hasChildren()) { foreach ($node->child as $child) { dump_tree($child, $indent + 3); } } }
function dump_tree(&$box, $level) { print str_repeat(" ", $level); print get_class($box) . ":" . $box->uid . "\n"; if (isset($box->content)) { for ($i = 0; $i < count($box->content); $i++) { dump_tree($box->content[$i], $level + 1); } } }
function dump_tree(&$box, $level) { print str_repeat(" ", $level); if (is_a($box, 'TextBox')) { print get_class($box) . ":" . $box->uid . ":" . join('/', $box->words) . "\n"; } else { print get_class($box) . ":" . $box->uid . "\n"; } if (isset($box->content)) { for ($i = 0; $i < count($box->content); $i++) { dump_tree($box->content[$i], $level + 1); } } }