note 54638 added to function.simplexml-element-xpath

From: Date: Mon, 11 Jul 2005 01:16:03 +0000
Subject: note 54638 added to function.simplexml-element-xpath
Groups: php.notes 
Request: Send a blank email to php-notes+get-91754@lists.php.net to get a copy of this message
xpath() can also be used to select elements by their attributes. For a good XPath reference check out: http://www.w3schools.com/xpath/xpath_syntax.asp <?php $string = <<<XML <sizes> <size label="Square" width="75" height="75" /> <size label="Thumbnail" width="100" height="62" /> <size label="Small" width="112" height="69" /> <size label="Large" width="112" height="69" /> </sizes> XML; $xml = simplexml_load_string($string); $result = $xml->xpath("//size[@label='Large']"); // print the first (and only) member of the array echo $result[0]->asXml(); ?> The script would print: <size label="Large" width="112" height="69"/> ---- Manual Page -- http://www.php.net/manual/en/function.simplexml-element-xpath.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54638 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54638&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54638&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54638&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54638&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54638&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54638&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54638&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#91754) next »