note 63736 added to function.simplexml-element-xpath

From: Date: Wed, 29 Mar 2006 17:07:05 +0000
Subject: note 63736 added to function.simplexml-element-xpath
Groups: php.notes 
Request: Send a blank email to php-notes+get-106952@lists.php.net to get a copy of this message
xpath returning references to the parent simplexml object can bite you performance wise when processing large trees. this bit me big time so looking for a solution I came up with a simple way to speed up the code. 'dereferencing' will yield instant results, code will be lighting fast. sacrifice is losing the reference to the parent object, for simple read-only operation this should be ok. <?php $data = 'data.xml'; $rs = simplexml_load_file($data); foreach($rs->xpath('//row') as $rsrow){ // 'derefence' into a seperate xml tree for performance $row = simplexml_load_string($rsrow->asXML()); $v = $row->xpath('//field[@name="id"]'); } ?> ---- Server IP: 66.163.161.117 Probable Submitter: 213.84.2.96 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.simplexml-element-xpath.php Edit -- http://master.php.net/note/edit/63736 Del: integrated -- http://master.php.net/note/delete/63736/integrated Del: useless -- http://master.php.net/note/delete/63736/useless Del: bad code -- http://master.php.net/note/delete/63736/bad+code Del: spam -- http://master.php.net/note/delete/63736/spam Del: non-english -- http://master.php.net/note/delete/63736/non-english Del: in docs -- http://master.php.net/note/delete/63736/in+docs Del: other reasons-- http://master.php.net/note/delete/63736 Reject -- http://master.php.net/note/reject/63736 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#106952) next »