note 25964 added to function.domxml-xmltree

From: Date: Sun, 13 Oct 2002 05:18:20 +0000
Subject: note 25964 added to function.domxml-xmltree
Groups: php.notes 
Request: Send a blank email to php-notes+get-38002@lists.php.net to get a copy of this message
Same concept as previous function, except uses node names as key items in the arrays. This function may prove a bit more useful than the previous one: function domxml_xmlarray($branch) { $object = array(); $objptr = &$object; $branch = $branch->first_child(); while ($branch) { if (!($branch->is_blank_node())) { switch ($branch->node_type()) { case XML_TEXT_NODE: { $objptr['cdata'] = $branch->node_value(); break; } case XML_ELEMENT_NODE: { $objptr = &$object[$branch->node_name()][]; break; } } if ($branch->has_child_nodes()) { $objptr = array_merge($objptr, domxml_xmlarray($branch)); } } $branch = $branch->next_sibling(); } return $object; } Usage is identical to the previous function. -- http://www.php.net/manual/en/function.domxml-xmltree.php http://master.php.net/manage/user-notes.php?action=edit+25964 http://master.php.net/manage/user-notes.php?action=delete+25964 http://master.php.net/manage/user-notes.php?action=reject+25964

« previous php.notes (#38002) next »