note 101014 added to class.domdocument
| From: | evert at er dot nl | Date: | Sat, 20 Nov 2010 10:17:48 +0000 |
| Subject: | note 101014 added to class.domdocument | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-174218@lists.php.net to get a copy of this message | ||
update (old message can be removed?), this one is a few lines smaller :)
function getArray($node)
{
$array = false;
if ($node->hasAttributes())
{
foreach ($node->attributes as $attr)
{
$array[$attr->nodeName] = $attr->nodeValue;
}
}
if ($node->hasChildNodes())
{
if ($node->childNodes->length == 1)
{
$array[$node->firstChild->nodeName] = $node->firstChild->nodeValue;
}
else
{
foreach ($node->childNodes as $childNode)
{
if ($childNode->nodeType != XML_TEXT_NODE)
{
$array[$childNode->nodeName][] = $this->getArray($childNode);
}
}
}
}
return $array;
}
----
Server IP: 91.199.167.223
Probable Submitter: 217.121.212.191
----
Manual Page -- http://www.php.net/manual/en/class.domdocument.php
Edit -- https://master.php.net/note/edit/101014
Del: integrated -- https://master.php.net/note/delete/101014/integrated
Del: useless -- https://master.php.net/note/delete/101014/useless
Del: bad code -- https://master.php.net/note/delete/101014/bad+code
Del: spam -- https://master.php.net/note/delete/101014/spam
Del: non-english -- https://master.php.net/note/delete/101014/non-english
Del: in docs -- https://master.php.net/note/delete/101014/in+docs
Del: other reasons-- https://master.php.net/note/delete/101014
Reject -- https://master.php.net/note/reject/101014
Search -- https://master.php.net/manage/user-notes.php