note 91567 added to function.simplexml-element-xpath
| From: | AntiVeeranna at osu1 dot php dot net | Date: | Wed, 17 Jun 2009 10:50:22 +0000 |
| Subject: | note 91567 added to function.simplexml-element-xpath | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-156959@lists.php.net to get a copy of this message | ||
Whether it returns a false or empty array for a non-existing path seems to depend on libxml version.
I tried the following code:
<?php
$data = '<foo><bar></bar></foo>';
$xml = simplexml_load_string($data);
print gettype($xml->xpath('/first/second'));
?>
On a machine with libxml 2.6.16 and PHP 5.2.8 I got back boolean. On a different machine with libxml
2.7.3 and PHP 5.2.8/5.2.9 I got back empty array.
You can check the libxml version from command line by executing: php --ri libxml
or simply look at phpinfo() output
----
Server IP: 64.71.164.2
Probable Submitter: 194.126.108.2
----
Manual Page -- http://www.php.net/manual/en/function.simplexml-element-xpath.php
Edit -- https://master.php.net/note/edit/91567
Del: integrated -- https://master.php.net/note/delete/91567/integrated
Del: useless -- https://master.php.net/note/delete/91567/useless
Del: bad code -- https://master.php.net/note/delete/91567/bad+code
Del: spam -- https://master.php.net/note/delete/91567/spam
Del: non-english -- https://master.php.net/note/delete/91567/non-english
Del: in docs -- https://master.php.net/note/delete/91567/in+docs
Del: other reasons-- https://master.php.net/note/delete/91567
Reject -- https://master.php.net/note/reject/91567
Search -- https://master.php.net/manage/user-notes.php