Re: print_r() and SimpleXML
| From: | Rick Fletcher | Date: | Wed, 01 Dec 2004 07:34:14 +0000 |
| Subject: | Re: print_r() and SimpleXML | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-203209@lists.php.net to get a copy of this message | ||
[snip]
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). [snip]
Now, if people agree with me, that this is infact not the desired response. Is this a 'bug' with SimpleXML or print_r?On the SimpleXML->attributes documentation page (http://www.php.net/manual/en/function.simplexml-element-attributes.php) you'll find this note: "SimpleXML has made a rule of adding iterative properties to most methods. They cannot be viewed using var_dump() or anything else which can examine objects." A pain? Maybe. A bug? No. There are a couple of user functions in the SimpleXML documentation comments that will convert a SimpleXML object to an array. You can then pass that array to print_r for debugging. Find the code here: http://www.php.net/manual/en/ref.simplexml.php Cheers, Rick