note 37758 added to ref.domxml

From: Date: Tue, 25 Nov 2003 17:43:23 +0000
Subject: note 37758 added to ref.domxml
Groups: php.notes 
Request: Send a blank email to php-notes+get-60980@lists.php.net to get a copy of this message
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; } } ?> ---- Manual Page -- http://www.php.net/manual/en/ref.domxml.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+37758 Delete -- http://master.php.net/manage/user-notes.php?action=delete+37758&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+37758&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#60980) next »