php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #28539 A problem with namespaces in SimpleXML
Submitted: 2004-05-27 09:14 UTC Modified: 2004-06-07 09:36 UTC
From: j dot uribe at globalforma dot com Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5.0.0RC2 OS: XP
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
37 - 21 = ?
Subscribe to this entry?

 
 [2004-05-27 09:14 UTC] j dot uribe at globalforma dot com
Description:
------------
Hi!

-When i try access to a tag with namespaces like <namespace:tag>Content</namespace:tag> i can't do it, if i make a print_r($xml) i can see that tag, but i can not access to it by $xml->namespace:tag (this is an error) or $xml->tag

-The only way to solve this is make $m=get_object_vars($xml) so i receive a array with all the elements so i can access to it, but in the case that namespace belongs to an attribute like <element namespace:attrib="something"></element> this is not possible and i can not access to it.

Thx.

Reproduce code:
---------------
$string="<xml>
<parent element:attrib>
<element:tag>content</element>
</parent>
</xml>";

$xml=simplexml_load_string($string));

print_r($xml->parent);<-this works fine;
print_r($xml->parent->element);
echo "$xml->parent->elementecho "$xml->attrib";";<-these does not produce any output.


Expected result:
----------------
I expected to see the content of the <element:tag> but i can not see anything so i can not see the content of the element attrib.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-06-07 09:36 UTC] chregu@php.net
The namespace handling of simplexml is somehow 
different.

check http://zend.com/php5/articles/php5-
simplexml.php#Heading3 to see how it's done.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 04:01:28 2024 UTC