ID:               41584
 User updated by:  judas dot iscariote at gmail dot com
 Reported By:      judas dot iscariote at gmail dot com
-Status:           Assigned
+Status:           Closed
 Bug Type:         SimpleXML related
 Operating System: any
 PHP Version:      5CVS-2007-06-04 (CVS)
 Assigned To:      helly
 New Comment:

This bug was fixed in CVS among with #41582( thanks dmitry ;) )


Previous Comments:
------------------------------------------------------------------------

[2007-06-04 12:15:47] judas dot iscariote at gmail dot com

I can use

either :

$xml->movie[0]->addChild('character')->addChild('name', 'ouch');

or:

$xml->movie[0]->addChild('character')->name = 'ouch';

To create the second element and then keep working with

$xml->movie[n]->characters->character[n] -> foo = 'bar' as usual.

is just the operation the create a new (second) "character"
automatically after the first element using [n] does not work.

------------------------------------------------------------------------

[2007-06-04 12:06:01] [EMAIL PROTECTED]

After a discussion with Christian, I do agree that there is something
wrong with the logics SimpleXML uses.
When you use $obj->element[0] it actually uses $obj->element (well, I
can see the reasoning, but it's a bit non-obvious). On the other hand,
when you try to write $obj->element[1], the result is NULL 'cause there
is no element #1.

I guess sxe_prop_dim_read() should automatically create elements when
used with BP_VAR_W/BP_VAR_RW.
Marcus, what do you think about it?

------------------------------------------------------------------------

[2007-06-04 11:12:37] [EMAIL PROTECTED]

IMO the warning is correct and the code is not.
I don't understand what you're trying to do with $object[0]->property -
is this supposed to created a property named '0' and assign an empty
object to it?

------------------------------------------------------------------------

[2007-06-04 10:09:37] judas dot iscariote at gmail dot com

Description:
------------
[different problem, but a follow up of bug 41582


The following code emits a wrong notice, rendering this stuff more or
less useless in write context...



Reproduce code:
---------------
<?php

$xml = new SimpleXMLElement('<?xml version="1.0" standalone="yes"?>
<collection></collection>');

$xml->movie[0]->characters->character[0]->name = 'Miss Coder';
$xml->movie[0]->characters->character[1]->name = 'ouch';

var_dump($xml->asXML());


Expected result:
----------------
string(%d) "<?xml version="1.0" standalone="yes"?>
<collection><movie><characters><character><name>Miss
Coder</name></character><character><name>ouch</name></character></characters></movie></collection>
"

Actual result:
--------------
PHP Notice:  Indirect modification of overloaded element of
SimpleXMLElement has no effect in /home/cristian/simplecrashes.php on
line 6
string(151) "<?xml version="1.0" standalone="yes"?>
<collection><movie><characters><character><name>Miss
Coder</name></character></characters></movie></collection>
"



------------------------------------------------------------------------


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

Reply via email to