note 26023 deleted from function.domxml-xmltree by sobak

From: Date: Tue, 22 Nov 2016 03:39:57 +0000
Subject: note 26023 deleted from function.domxml-xmltree by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-207390@lists.php.net to get a copy of this message
Note Submitter: nospam at candlefire dot org ---- Consider the following revisions for including attributes into the array. 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 ()][]; 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; }

« previous php.notes (#207390) next »