php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51517 Node attributes lost when it has both attributes and value
Submitted: 2010-04-09 04:31 UTC Modified: 2010-04-09 09:13 UTC
From: zhangxc83 at sohu dot com Assigned:
Status: Closed Package: SimpleXML related
PHP Version: 5.3.2 OS: Linux 2.6.18-92.el5
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: zhangxc83 at sohu dot com
New email:
PHP Version: OS:

 

 [2010-04-09 04:31 UTC] zhangxc83 at sohu dot com
Description:
------------
AS Test Scripts below:

Test script:
---------------
$xml = <<<EOT
<?xml version="1.0" encoding="UTF-8"?>
<root>
<report id="testid">test value</report>
</root>
EOT;

$xml = new \SimpleXMLElement(trim($xml));
print_r($xml);


Expected result:
----------------
.SimpleXMLElement Object
(
    [report] => .SimpleXMLElement Object
(
    [@attributes] => Array
        (
            [id] => testid
        )

    [0] => test value
)
)



Actual result:
--------------
.SimpleXMLElement Object
(
    [report] => test value
)


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-09 04:35 UTC] rasmus@php.net
They are not lost.  It is just a deficiency in print_r walking from the root 
node.  Try this:

print_r($xml->report);
 [2010-04-09 09:13 UTC] zhangxc83 at sohu dot com
-Status: Open +Status: Closed
 [2010-04-09 09:13 UTC] zhangxc83 at sohu dot com
It works. Thanks a lot.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Apr 29 18:01:30 2024 UTC