From:             lists at cyberlot dot net
Operating system: Fedora Core 2
PHP version:      5.0.0
PHP Bug Type:     SimpleXML related
Bug description:  Accessing object elements returns object

Description:
------------
When using simplexml to access a element the returned object it returns a
object instead of a string

Have to type cast it as a (string) to get the information back, Should not
have to typecast.

If a typecast is required it should be specificed in the docs.

Reproduce code:
---------------
$string = <<<XML
<?xml version='1.0'?>
<document>
    <cmd>login</cmd>
    <login>Richard</login>
</document>
XML;
                                                                          
                                         
$xml = simplexml_load_string($string);
print_r($xml);
$login = $xml->login;
print_r($login);
$login = (string) $xml->login;
print_r($login);


Expected result:
----------------
SimpleXMLElement Object
(
    [cmd] => login
    [login] => Richard
)
Richard
Richard

Actual result:
--------------
SimpleXMLElement Object
(
    [cmd] => login
    [login] => Richard
)
SimpleXMLElement Object
(
    [0] => Richard
)
Richard

-- 
Edit bug report at http://bugs.php.net/?id=29500&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=29500&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=29500&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=29500&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=29500&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=29500&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=29500&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=29500&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=29500&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=29500&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=29500&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=29500&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=29500&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=29500&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=29500&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=29500&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=29500&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=29500&r=float

Reply via email to