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

From: Date: Sat, 16 Feb 2013 21:37:41 +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-176657@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:

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


Previous Comments:
------------------------------------------------------------------------
[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 (#176657) next »