note 91567 modified in function.simplexml-element-xpath by danbrown

From: Date: Wed, 16 Sep 2009 15:50:14 +0000
Subject: note 91567 modified in function.simplexml-element-xpath by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-160671@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 --was-- 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 http://php.net/manual/en/function.simplexml-element-xpath.php

« previous php.notes (#160671) next »