note 93832 deleted from class.domnodelist by joey

From: Date: Tue, 16 Oct 2012 00:54:29 +0000
Subject: note 93832 deleted from class.domnodelist by joey
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-191311@lists.php.net to get a copy of this message
Note Submitter: A dot Lepe dev+php at alepe dot com ---- 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.

« previous php.notes (#191311) next »