note 26023 added to function.domxml-xmltree

From: Date: Tue, 15 Oct 2002 13:03:08 +0000
Subject: note 26023 added to function.domxml-xmltree
Groups: php.notes 
Request: Send a blank email to php-notes+get-38111@lists.php.net to get a copy of this message
Consider the following revisions for including attributes into the array. function domxml_xmlarray ($branch) { $object = Array (); $objptr =& $obj; $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 ()][]; if ($branch->has_attributes ()) { $attributes = $branch->attributes (); if (!is_array ($attributes)) { break; } foreach ($attributes as $index => $domobj) { $objptr[$index] = $objptr[$domobj->name] = $domobj->value; } } break; } } if ($branch->has_child_nodes ()) { $objptr = array_merge ($objptr, domxml_xmlarray ($branch)); } } $branch = $branch->next_sibling (); } return $object; } -- http://www.php.net/manual/en/function.domxml-xmltree.php http://master.php.net/manage/user-notes.php?action=edit+26023 http://master.php.net/manage/user-notes.php?action=delete+26023 http://master.php.net/manage/user-notes.php?action=reject+26023

« previous php.notes (#38111) next »