|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2013-02-16 21:37 UTC] schalk at unf dot edu
[2013-02-16 21:48 UTC] schalk at unf dot edu
[2013-02-18 18:30 UTC] schalk at unf dot edu
[2013-02-18 21:21 UTC] salathe@php.net
-Status: Open
+Status: Duplicate
[2013-02-18 21:21 UTC] salathe@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Oct 26 22:00:01 2025 UTC |
Description: ------------ In PHP 5.4 xpath() returns SimpleXMLObjects which casted to array give empty arrays. If tags have text values they aren't present in object like in PHP 5.3. Test script: --------------- $xml = simplexml_load_string(' <person> <profile> <name>PHP developer</name> </profile> </person>'); // get all names $xml = $xml->xpath('/person/profile/name'); // get first result $xml = reset($xml); // show result print_r($xml); Expected result: ---------------- In PHP 5.3 the (expected) result is SimpleXMLElement Object ( [0] => PHP developer ) Casting this to an array will result: array(0 => 'PHP developer') which is ok. Actual result: -------------- In PHP 5.4 the result is SimpleXMLElement Object ( ) If we cast this to an array will result an empty array, but we expected text values.