Edit report at http://bugs.php.net/bug.php?id=29500&edit=1

 ID:                 29500
 Comment by:         stu at dyndev dot co dot nz
 Reported by:        lists at cyberlot dot net
 Summary:            Accessing object elements returns object
 Status:             Wont fix
 Type:               Bug
 Package:            SimpleXML related
 Operating System:   Fedora Core 2
 PHP Version:        5.0.0
 Block user comment: N
 Private report:     N

 New Comment:

This intentional bug is still there, I cannot for the life of me see why
it would be that way or why it's still not documented all these years
later.


Previous Comments:
------------------------------------------------------------------------
[2004-08-03 15:39:41] lists at cyberlot dot net

Ok it is impossible to modify the simpleobject once creating which means
you can't add anything to the xml.



Is this a desired affect as well?

------------------------------------------------------------------------
[2004-08-03 15:29:03] lists at cyberlot dot net

Im not signed up for that list...

The online docs badly need updating then.



1. To express the need to use typecasting depending on how you access
the variable.



2. That you can no longer "change" the simplexml object like explained
in example 7

------------------------------------------------------------------------
[2004-08-03 12:01:13] chr...@php.net

That's by design and was discussed on 

intern...@lists.php.net

------------------------------------------------------------------------
[2004-08-03 05:23:22] lists at cyberlot dot net

http://us3.php.net/manual/en/ref.simplexml.php



In trying to get this working I played with the examples from this
page.



Example 7 returns the following error

Fatal error: Objects used as arrays in post/pre increment/decrement must
return values by reference in /root/test.php on line 29

------------------------------------------------------------------------
[2004-08-03 05:15:42] lists at cyberlot dot net

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 this bug report at http://bugs.php.net/bug.php?id=29500&edit=1

Reply via email to