Edit report at https://bugs.php.net/bug.php?id=62203&edit=1

 ID:                 62203
 Comment by:         schalk at unf dot edu
 Reported by:        phpdev at mailmetrash dot com
 Summary:            xpath doesn't return tag values
 Status:             Open
 Type:               Bug
 Package:            SimpleXML related
 PHP Version:        5.4.3
 Block user comment: N
 Private report:     N

 New Comment:

I checked both the current 5.3 and 5.4 source for the xpath simplexml function 
and they are the same.  So, this means that the error is somewhere else.  Could 
this be because of the change in how 5.4 deals with arrays?


Previous Comments:
------------------------------------------------------------------------
[2013-02-16 21:48:08] schalk at unf dot edu

I just checked and this is not fixed in 5.5.0alpha4 either!  Do I really have 
to go back to 5.3?

------------------------------------------------------------------------
[2013-02-16 21:37:41] schalk at unf dot edu

When is this going to be fixed.  I have reproduced it in 5.4.11 and it is kind 
of a major bug that has caused me a significant amount of wasted debug time.

Stuart

------------------------------------------------------------------------
[2012-06-01 07:43:32] phpdev at mailmetrash dot com

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.


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=62203&edit=1

Reply via email to