php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41172 SimpleXML empty attributes
Submitted: 2007-04-23 15:41 UTC Modified: 2007-04-24 14:05 UTC
From: fedelman at gmail dot com Assigned:
Status: Closed Package: DOM XML related
PHP Version: 5.2.1 OS: *
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: fedelman at gmail dot com
New email:
PHP Version: OS:

 

 [2007-04-23 15:41 UTC] fedelman at gmail dot com
Description:
------------
When I've got a node with one attribute and text, the SimpleXML does not return the attribute, it only return the text.

Please, see the example.

I think may be it's this is a bug.

Reproduce code:
---------------
$strXml = "
<root>
        <data myattr=\"This is the value\">This is the text</data>
</root>";

$oXML=simplexml_load_string($strXml);
echo "<pre>";
var_dump($oXML);
echo "</pre>";


Expected result:
----------------
object(SimpleXMLElement)#1 (2) {
    ["@attributes"]=>
    array(1) {
      ["myattr1"]=>
      string(17) "This is the value"
    }
    string(16) "This is the text"
}



Actual result:
--------------
object(SimpleXMLElement)#1 (1) {
  ["data"]=>
  string(16) "This is the text"
}

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-04-23 17:42 UTC] helly@php.net
Try: var_dump($oXML[0]);
 [2007-04-24 14:05 UTC] fedelman at gmail dot com
There is no bug. It's my mistake. Cannot dump full internal object SimpleXMLElement.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 16 18:01:30 2024 UTC