note 37758 deleted from ref.domxml by didou

From: Date: Sun, 29 Aug 2004 21:46:30 +0000
Subject: note 37758 deleted from ref.domxml by didou
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-75596@lists.php.net to get a copy of this message
Note Submitter: phpdocs at pointbeing dot net ---- FWIW, here's bart @ mediawave's extremely useful function, rewritten using current PHP coding conventions: <?php function PrintDomTree($DomNode) { if ($ChildDomNode = $DomNode->first_child()) { static $depth = 0; $whitespace = "\n<br>".str_repeat("&nbsp;", ($depth * 2)); while ($ChildDomNode) { if ($ChildDomNode->node_type() == XML_TEXT_NODE) { echo trim($ChildDomNode->node_value()); } elseif ($ChildDomNode->node_type() == XML_ELEMENT_NODE) { $HasTag = 1; echo $whitespace; echo "&lt;", $ChildDomNode->node_name(); if ($ChildDomNode->has_attributes()) { $Array = $ChildDomNode->attributes(); foreach ($Array AS $DomAttribute) { echo " ", $DomAttribute->name(), "=\"", $DomAttribute->value(), "\""; } } echo "&gt;"; if ($ChildDomNode->has_child_nodes()) { $depth++; if (PrintDomTree($ChildDomNode)) { echo $whitespace; } $depth--; } echo "&lt;/", $ChildDomNode->node_name(), "&gt;"; } $ChildDomNode = $ChildDomNode->next_sibling(); } return $HasTag; } } ?>

« previous php.notes (#75596) next »