Doc #53633 [Asn->Csd]: SimpleXML incorrectly gives NULL for attributes() with XPath value expression
| From: | aharvey@php.net | Date: | Tue, 04 Jan 2011 13:33:57 +0000 |
| Subject: | Doc #53633 [Asn->Csd]: SimpleXML incorrectly gives NULL for attributes() with XPath value expression | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-5745@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=53633&edit=1
ID: 53633
Updated by: aharvey@php.net
Reported by: barry at 091labs dot com
Summary: SimpleXML incorrectly gives NULL for attributes()
with XPath value expression
-Status: Assigned
+Status: Closed
Type: Documentation Problem
Package: Documentation problem
Operating System: Windows XP
PHP Version: 5.3SVN-2010-12-30 (SVN)
Assigned To: aharvey
Block user comment: N
Private report: N
New Comment:
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.
Thank you for the report, and for helping us make our documentation
better.
Previous Comments:
------------------------------------------------------------------------
[2011-01-04 14:33:51] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&revision=307081
Log: Fix doc bug #53633 (SimpleXML incorrectly gives NULL for
attributes() with
XPath value expression).
------------------------------------------------------------------------
[2011-01-04 14:28:08] aharvey@php.net
Actually changing the bug type, which got reset when I previewed. Sorry
about the noise.
------------------------------------------------------------------------
[2011-01-04 14:27:46] aharvey@php.net
Morphing into a documentation bug: this is intentional per a comment in
the SimpleXML source (SimpleXMLElement instances representing
attributes instead of tags deliberately return NULL when attributes()
is called), but needs to be documented on the
SimpleXMLElement::attributes() manual page.
------------------------------------------------------------------------
[2010-12-30 08:35:44] barry at 091labs dot com
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 this bug report at http://bugs.php.net/bug.php?id=53633&edit=1