note 84294 added to book.dom

From: Date: Tue, 08 Jul 2008 08:56:48 +0000
Subject: note 84294 added to book.dom
Groups: php.notes 
Request: Send a blank email to php-notes+get-141261@lists.php.net to get a copy of this message
I have a problem with function. Function should search DOMNodList $res for a node with the attributes. If it's not matches all of the attributes of the node it should be removed from the DOMNodeList $res. How can do it? /////////////////////////////// function findTag_all(DOMDocument &$doc,$tag_name,array $where=array()){ $res = $doc->getElementsByTagName($tag_name); $c = count($where); for($i=0;$res->item($i);$i++){ $f = 0; foreach($where as $k=>$v){ $f = (ereg($v,$res->item($i)->getAttribute($k)))?++$f:$f; } if($f!=$c){ // i need this element to remove from the object $res $res->item($i); } } return $res; } $file = 'http://example.com/'; $doc = new DOMDocument('1.0'); $doc->loadHTMLFile($file); $nods =findTag_all($doc,'div',array("id"=>"test")); for($i=0;$tag->item($i);$i++){ var_dump($nods->item($i)->nodeValue); } ---- Server IP: 195.54.192.44 Probable Submitter: 127.0.0.1 ---- Manual Page -- http://www.php.net/manual/en/book.dom.php Edit -- https://master.php.net/note/edit/84294 Del: integrated -- https://master.php.net/note/delete/84294/integrated Del: useless -- https://master.php.net/note/delete/84294/useless Del: bad code -- https://master.php.net/note/delete/84294/bad+code Del: spam -- https://master.php.net/note/delete/84294/spam Del: non-english -- https://master.php.net/note/delete/84294/non-english Del: in docs -- https://master.php.net/note/delete/84294/in+docs Del: other reasons-- https://master.php.net/note/delete/84294 Reject -- https://master.php.net/note/reject/84294 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#141261) next »