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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?

Dante

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux