print_r() and SimpleXML

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux