|  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.
Block user comment
Status: Assign to:
Bug Type:
From: zhangxc83 at sohu dot com
New email:
PHP Version: OS:


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

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

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

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

    [0] => test value

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


Add a Patch

Pull Requests

Add a Pull Request


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

 [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 Jul 22 09:01:28 2024 UTC