#28539 [Opn->Bgs]: A problem with namespaces in SimpleXML

From: Date: Mon, 07 Jun 2004 07:36:57 +0000
Subject: #28539 [Opn->Bgs]: A problem with namespaces in SimpleXML
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-60467@lists.php.net to get a copy of this message
ID: 28539 Updated by: chregu@php.net Reported By: j dot uribe at globalforma dot com -Status: Open +Status: Bogus Bug Type: SimpleXML related Operating System: XP PHP Version: 5.0.0RC2 New Comment: The namespace handling of simplexml is somehow different. check http://zend.com/php5/articles/php5- simplexml.php#Heading3 to see how it's done. Previous Comments: ------------------------------------------------------------------------ [2004-05-27 09:14:16] 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. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=28539&edit=1

« previous php.bugs (#60467) next »