note 73875 added to ref.dom
| From: | Yanik | Date: | Wed, 14 Mar 2007 07:40:41 +0000 |
| Subject: | note 73875 added to ref.dom | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124431@lists.php.net to get a copy of this message | ||
I hate DOM model !
so I wrote dom2array simple function (simple for use):
function dom2array($node) {
$res = array();
print $node->nodeType.'<br/>';
if($node->nodeType == XML_TEXT_NODE){
$res = $node->nodeValue;
}
else{
if($node->hasAttributes()){
$attributes = $node->attributes;
if(!is_null($attributes)){
$res['@attributes'] = array();
foreach ($attributes as $index=>$attr) {
$res['@attributes'][$attr->name] = $attr->value;
}
}
}
if($node->hasChildNodes()){
$children = $node->childNodes;
for($i=0;$i<$children->length;$i++){
$child = $children->item($i);
$res[$child->nodeName] = dom2array($child);
}
}
}
return $res;
}
----
Server IP: 212.199.163.191
Probable Submitter: 132.72.45.209
----
Manual Page -- http://www.php.net/manual/en/ref.dom.php
Edit -- https://master.php.net/note/edit/73875
Del: integrated -- https://master.php.net/note/delete/73875/integrated
Del: useless -- https://master.php.net/note/delete/73875/useless
Del: bad code -- https://master.php.net/note/delete/73875/bad+code
Del: spam -- https://master.php.net/note/delete/73875/spam
Del: non-english -- https://master.php.net/note/delete/73875/non-english
Del: in docs -- https://master.php.net/note/delete/73875/in+docs
Del: other reasons-- https://master.php.net/note/delete/73875
Reject -- https://master.php.net/note/reject/73875
Search -- https://master.php.net/manage/user-notes.php