note 93832 added to class.domnodelist

From: Date: Fri, 02 Oct 2009 05:53:53 +0000
Subject: note 93832 added to class.domnodelist
Groups: php.notes 
Request: Send a blank email to php-notes+get-161213@lists.php.net to get a copy of this message
Using NodeLists to store results of an XQuery is not very functional if you are planning to do some operations with those Nodes. Instead, you can use an array in this way: <?php $nodelist = $xpath->query($xpath, $DOMdoc); foreach ($nodelist as $node) { // you can add here a special conditions, as searching for // regular expression matches in your nodes names/values/attributes // which can not be achieved with XSLT 1.0 if( .... ) $nodearr[] = $node; } ?> This way, you can access nodes like (for example): <?php $nodearr[0]->nodeValue; ?> solving the problem described by "saad0105050" (06-Jul-2008) Even more, you can perform other operations in your results as removing elements, reversing order, randomize, callbacks, etc. ---- Server IP: 209.41.74.194 Probable Submitter: 211.6.179.194 ---- Manual Page -- http://www.php.net/manual/en/class.domnodelist.php Edit -- https://master.php.net/note/edit/93832 Del: integrated -- https://master.php.net/note/delete/93832/integrated Del: useless -- https://master.php.net/note/delete/93832/useless Del: bad code -- https://master.php.net/note/delete/93832/bad+code Del: spam -- https://master.php.net/note/delete/93832/spam Del: non-english -- https://master.php.net/note/delete/93832/non-english Del: in docs -- https://master.php.net/note/delete/93832/in+docs Del: other reasons-- https://master.php.net/note/delete/93832 Reject -- https://master.php.net/note/reject/93832 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#161213) next »