note 51469 added to ref.dom

From: Date: Thu, 31 Mar 2005 15:25:33 +0000
Subject: note 51469 added to ref.dom
Groups: php.notes 
Request: Send a blank email to php-notes+get-87273@lists.php.net to get a copy of this message
my bad..its not an attribute ..its a text element node so if one checks for that, it can be easily corrected. Wrote the corrected function. I hope it takes care of all conditions. If someone finds any issues with it, I would be glad to know about it. function readXml($domnode, &$array) { $array_ptr = &$array; $domnode = $domnode->firstChild; while (!is_null($domnode)) { switch ($domnode->nodeType) { case XML_TEXT_NODE: if(!(trim($domnode->nodeValue) == "")) $array_ptr['cdata'] = $domnode->nodeValue; break; case XML_ELEMENT_NODE: $array_ptr = &$array[$domnode->nodeName][]; if ($domnode->hasAttributes() ) { $attributes = $domnode->attributes; foreach ($attributes as $index => $domobj) { $array_ptr[$domobj->name] = $domobj->value; } } break; } if ( $domnode->hasChildNodes() ) { readXml($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+51469 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51469&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51469&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51469&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51469&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51469&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+51469&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#87273) next »