php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40539 Invisible attributes in XML loaded with default namespace
Submitted: 2007-02-19 10:01 UTC Modified: 2007-03-26 20:39 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: vrana@php.net Assigned: helly (profile)
Status: Not a bug Package: SimpleXML related
PHP Version: 5.2.1 OS: Windows
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: vrana@php.net
New email:
PHP Version: OS:

 

 [2007-02-19 10:01 UTC] vrana@php.net
Description:
------------
When I load XML with fourth attribute of simplexml_load_file or simplexml_load_string, attributes are invisible. It's irrelevant if namespace is default (xmlns=) or prefixed (xmlns:x=).

Reproduce code:
---------------
$text = '<a xmlns="http://example.org"><c a="d">test</c></a>';
$xml = simplexml_load_string($text, null, 0, "http://example.org");
var_dump($xml->c["a"]);


Expected result:
----------------
object(SimpleXMLElement)#4 (1) {
  [0]=>
  string(1) "d"
}

Actual result:
--------------
NULL

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-03-26 20:39 UTC] rrichards@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You just set the namespace scope - same as if you used $xml->children("http://example.org") - to use for operations. It needs to be removed for the attributes:
$atts = $xml->c->attributes();
var_dump($atts["a"]);

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 13:01:30 2024 UTC