note 57252 deleted from ref.xml by bjori

From: Date: Mon, 09 Oct 2006 11:12:22 +0000
Subject: note 57252 deleted from ref.xml by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-118281@lists.php.net to get a copy of this message
Note Submitter: jbernau at muc dot de ---- I liked the xmlparser class by monte (see next comment) very much. So here is my small addition to it. usage: <?php $p =& new xmlParser(); $p->parse('http://domain.com/rss.xml'); $node = $p->GetNodeByPath("root/leaf/leaf2"); print $node[content]; print $node[attrs][my_attr]; ?> The new member function to class xmlparser: <?php function GetNodeByPath($path,$tree = false) { if ($tree) { $tree_to_search = $tree; } else { $tree_to_search = $this->output; } if ($path == "") { return null; } $arrPath = explode('/',$path); foreach($tree_to_search as $key => $val) { if (gettype($val) == "array") { $nodename = $val[name]; if ($nodename == $arrPath[0]) { if (count($arrPath) == 1) { return $val; } array_shift($arrPath); $new_path = implode($arrPath,"/"); return $this->GetNodeByPath($new_path,$val[child]); } } } } ?>

« previous php.notes (#118281) next »