Simple HTML DOM Test
HTML STAT ()
-
ob_start();
foreach($target as $e)
dump_my_html_tree($e, true);
ob_end_flush();
?>
find('html', 0); if ($l!==null) $lang = $l->lang; if ($lang!='') $lang = 'lang="'.$lang.'"'; $charset = $html->find('meta[http-equiv*=content-type]', 0); $target = array(); $query = ''; if (isset($_REQUEST['query'])) { $query = $_REQUEST['query']; $target = $html->find($query); } function stat_dom($dom) { $count_text = 0; $count_comm = 0; $count_elem = 0; $count_tag_end = 0; $count_unknown = 0; foreach($dom->nodes as $n) { if ($n->nodetype==HDOM_TYPE_TEXT) ++$count_text; if ($n->nodetype==HDOM_TYPE_COMMENT) ++$count_comm; if ($n->nodetype==HDOM_TYPE_ELEMENT) ++$count_elem; if ($n->nodetype==HDOM_TYPE_ENDTAG) ++$count_tag_end; if ($n->nodetype==HDOM_TYPE_UNKNOWN) ++$count_unknown; } echo 'Total: '. count($dom->nodes). ', Text: '.$count_text. ', Commnet: '.$count_comm. ', Tag: '.$count_elem. ', End Tag: '.$count_tag_end. ', Unknown: '.$count_unknown; } function dump_my_html_tree($node, $show_attr=true, $deep=0, $last=true) { $count = count($node->nodes); if ($count>0) { if($last) echo '