From:
Operating system: Windows XP
PHP version: 5.3SVN-2010-12-30 (SVN)
Package: XML related
Bug Type: Bug
Bug description:SimpleXML incorrectly gives NULL for attributes() with XPath
value expression
Description:
------------
Apologies but I'm not running the SVN version as I only have hosting access
to
PHP, but I've searched through the bugs and have found nothing. Using
5.3.0, sorry
if this has already been fixed.
When using an XPath expression "/test/@attr1" to select one attribute,
attributes() returns NULL when it should return the single attribute
Test script:
---------------
<?php
$xml = simplexml_load_string("<test attr1=\"a\" attr2=\"b\"></test>");
$result = $xml->xpath("/test");
var_dump ($result[0]); //Prints attributes, all fine
var_dump ($result[0]->attributes()); //Works fine
$result = $xml->xpath("/test/@attr1");
var_dump ($result[0]); //Prints attribute "attr1", all fine
var_dump ($result[0]->attributes()); //Should print same as above but
returns null
?>
Expected result:
----------------
The last var_dump should have printed the same as the previous var_dump
Actual result:
--------------
The last var_dump printed null
--
Edit bug report at http://bugs.php.net/bug.php?id=53633&edit=1
--
Try a snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=53633&r=trysnapshot52
Try a snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=53633&r=trysnapshot53
Try a snapshot (trunk):
http://bugs.php.net/fix.php?id=53633&r=trysnapshottrunk
Fixed in SVN:
http://bugs.php.net/fix.php?id=53633&r=fixed
Fixed in SVN and need be documented:
http://bugs.php.net/fix.php?id=53633&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=53633&r=alreadyfixed
Need backtrace:
http://bugs.php.net/fix.php?id=53633&r=needtrace
Need Reproduce Script:
http://bugs.php.net/fix.php?id=53633&r=needscript
Try newer version:
http://bugs.php.net/fix.php?id=53633&r=oldversion
Not developer issue:
http://bugs.php.net/fix.php?id=53633&r=support
Expected behavior:
http://bugs.php.net/fix.php?id=53633&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=53633&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=53633&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=53633&r=globals
PHP 4 support discontinued: http://bugs.php.net/fix.php?id=53633&r=php4
Daylight Savings: http://bugs.php.net/fix.php?id=53633&r=dst
IIS Stability:
http://bugs.php.net/fix.php?id=53633&r=isapi
Install GNU Sed:
http://bugs.php.net/fix.php?id=53633&r=gnused
Floating point limitations:
http://bugs.php.net/fix.php?id=53633&r=float
No Zend Extensions:
http://bugs.php.net/fix.php?id=53633&r=nozend
MySQL Configuration Error:
http://bugs.php.net/fix.php?id=53633&r=mysqlcfg