SimpleXMLElement writing problem while in a reference

From: Date: Tue, 13 Jun 2006 13:50:07 +0000
Subject: SimpleXMLElement writing problem while in a reference
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-237889@lists.php.net to get a copy of this message
Hi all, I found out (while playing with xpath()) that you cant edit the content of a node when you use a reference on a SimpleXMLElement object. An example: --------------------------- $xmlString = '<?xml version="1.0" encoding="UTF-8"?> <container> <texte> <text user="user1">llllasdfasdfeorpqi</text> <text user="user2">oouzzrrzreorpqi</text> </texte> </container>'; $xml = simplexml_load_string($xmlString); $xml->texte->text[0] = 'newText'; // Works $xml->texte->text[0]['user'] = 'newUser'; // Works echo $xml->asXML() . "\n"; $xml = simplexml_load_string($xmlString); $xmlRef = $xml->texte->text[0]; // Creating a reference $xmlRef['user'] = 'newUser'; // Works $xmlRef = 'newUser'; // Doesnt Work! echo $xml->asXML() . "\n"; --------------------------- Am i doing something wrong. or is this a bug or what ? Hope for some help Bye Georg Nagel

« previous php.general (#237889) next »