note 48111 added to ref.dom

From: Date: Sun, 12 Dec 2004 12:17:55 +0000
Subject: note 48111 added to ref.dom
Groups: php.notes 
Request: Send a blank email to php-notes+get-81715@lists.php.net to get a copy of this message
Unfortunately jas at uci dot edu 's function doesn'T really work ;-) try this corrected version. It works even with complicated HTML.. greetings, TIMO <? function dom_to_simple_array($domnode, &$array) { $array_ptr = &$array; $domnode = $domnode->firstChild; while (!is_null($domnode)) { if (! (trim($domnode->nodeValue) == "") ) { switch ($domnode->nodeType) { case XML_TEXT_NODE: { $array_ptr['cdata'] = $domnode->nodeValue; break; } case XML_ELEMENT_NODE: { $array_ptr = &$array[$domnode->nodeName][]; if ($domnode->hasAttributes() ) { foreach ($domnode->attributes as $d_attribute){ $array_ptr[$d_attribute->name] = $d_attribute->value; } } break; } } if ( $domnode->hasChildNodes() ) { dom_to_simple_array($domnode, $array_ptr); } } $domnode = $domnode->nextSibling; } } ?> ---- Manual Page -- http://www.php.net/manual/en/ref.dom.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+48111 Delete -- http://master.php.net/manage/user-notes.php?action=delete+48111&report=yes Reason: bad code -- http://master.php.net/manage/user-notes.php?action=delete+48111&report=yes&reason=bad+code Reason: spam -- http://master.php.net/manage/user-notes.php?action=delete+48111&report=yes&reason=spam Reason: useless example -- http://master.php.net/manage/user-notes.php?action=delete+48111&report=yes&reason=useless+example Reason: contains commercial links -- http://master.php.net/manage/user-notes.php?action=delete+48111&report=yes&reason=contains+commercial+links Reason: useless note -- http://master.php.net/manage/user-notes.php?action=delete+48111&report=yes&reason=useless+note Reject -- http://master.php.net/manage/user-notes.php?action=reject+48111&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#81715) next »