note 56120 added to function.simplexml-element-xpath

From: Date: Wed, 24 Aug 2005 08:21:48 +0000
Subject: note 56120 added to function.simplexml-element-xpath
Groups: php.notes 
Request: Send a blank email to php-notes+get-94113@lists.php.net to get a copy of this message
Xpath actually returns an array full of references to elements in the parent SimpleXML object. Therefore, in addition to preserving attributes, you can actually modify them and the result will be reflected in the parent. Example: <?php $xml_str = <<<END <a> <b attr="foo"/> </a> END; $xml = simplexml_load_string ($xml_str); $result = $xml->xpath ('/a/b'); // returns an array with one element $result[0]['attr'] = 'bar'; print $xml->asXML (); ?> Outputs: <a> <b attr="bar"/> </a> ---- Manual Page -- http://www.php.net/manual/en/function.simplexml-element-xpath.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+56120 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+56120&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+56120&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+56120&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+56120&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+56120&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+56120&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+56120&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#94113) next »