|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-06-04 10:09 UTC] 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> " PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 16:00:01 2025 UTC |
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.