function showDOMNode(DOMNode $doc, &$tagcount) { foreach ($doc->childNodes as $node) { if (!empty($node->tagName)) { if (isset($tagcount[$node->tagName])) { $tagcount[$node->tagName] += 1; } else { $tagcount[$node->tagName] = 1; } } if ($node->hasChildNodes()) { showDOMNode($node, $tagcount); } } }
function showDOMNode(DOMNode $domNode, $level = 0) { $n = 0; foreach ($domNode->childNodes as $node) { $n++; print "\n\t [{$level}.{$n}] " . $node->nodeName . ':' . $node->nodeValue; if ($node->hasChildNodes()) { print "\n ----"; showDOMNode($node, $level + 1); } } }