print_r() and SimpleXML

From: Date: Tue, 30 Nov 2004 16:40:14 +0000
Subject: print_r() and SimpleXML
Groups: php.general 
Request: Send a blank email to php-general+get-203152@lists.php.net to get a copy of this message
Hi All, All of my research seems to indicate that print_r() and SimpleXML are amongst the two most usefull things to have when working with XML documents. However, when using print_r on a SimpleXML object that has attributes, the attributes are not shown. I would propose that this is not the desired response. When using print_r on an object, it should display all available information (even, as the manual indicates, private and/or protected properties). Sample Code: -- <?php $testcase = '<a> <b>foo</b> <c>foobar</c> <d c="foobar" /> </a>'; $xml = simplexml_load_string($testcase); echo "<pre>"; print_r($xml); echo "</pre>"; echo $xml->d['c']; ?> -- Output (from browser) -- SimpleXMLElement Object ( [b] => foo [c] => foobar [d] => SimpleXMLElement Object ( ) ) foobar -- Expected output (fictional): -- SimpleXMLElement Object ( [b] => foo [c] => foobar [d] => SimpleXMLElement Object ( [c] => foobar ) ) foobar -- Now, if people agree with me, that this is infact not the desired response. Is this a 'bug' with SimpleXML or print_r? thanks paul -- Paul Reinheimer Zend Certified Engineer

« previous php.general (#203152) next »