Re: SimpleXML is creating nodes when it shouldn't...

From: Date: Fri, 12 May 2006 07:51:24 +0000
Subject: Re: SimpleXML is creating nodes when it shouldn't...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-236053@lists.php.net to get a copy of this message
Hello D., Friday, May 12, 2006, 5:29:42 AM, you wrote: > I've recently upgraded to PHP 5.1.4 from 5.1.2 and noticed that in 5.1.3 > there were changes made to SimpleXML. Now, when I touch an element > which didn't used to exist, instead of acting like it didn't exist, it > creates it! That's horrible! > Well, this used to work: > <?php > $xmlstr = "<test><item>1</item></test>"; > $xml = simplexml_load_string($xmlstr); > print_r($xml); > foreach ($xml->nonexist as $nonexist) { > // do nothing > } > print_r($xml); ?>> > But now, the output of the print_r is different when I do it the second > time because the foreach statement created nodes: > SimpleXMLElement Object > ( > [item] => 1 > ) > SimpleXMLElement Object > ( > [item] => 1 > [nonexist] => SimpleXMLElement Object > ( > ) > ) > I think that's a bug and not a feature. Why was this changed? It is called write support. I think we are going to add a flag so that one can specify whether write support is enabled or not. -- Best regards, Marcus mailto:mail@marcus-boerger.de

« previous php.general (#236053) next »