Bug #62203 [Com]: xpath doesn't return tag values

From: Date: Mon, 18 Feb 2013 18:30:32 +0000
Subject: Bug #62203 [Com]: xpath doesn't return tag values
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-177192@lists.php.net to get a copy of this message
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


Thread (5 messages)

« previous php.bugs (#177192) next »