#39164 [Bgs]: SimpleXML : foreach create new node

From: Date: Mon, 16 Oct 2006 16:14:31 +0000
Subject: #39164 [Bgs]: SimpleXML : foreach create new node
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-103594@lists.php.net to get a copy of this message
 ID:               39164
 User updated by:  php at bouchery dot com
 Reported By:      php at bouchery dot com
 Status:           Bogus
 Bug Type:         SimpleXML related
 Operating System: Windows XP
 PHP Version:      5.1.6
 New Comment:

I didn't see that in the documentation.
Even if it's written, it's a strange behaviour and shoud be a change
request.

Reading data should not modify it.


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

[2006-10-16 15:57:41] helly@php.net

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to
report
a bug at http://bugs.php.net/how-to-report.php

.

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

[2006-10-16 11:49:37] php at bouchery dot com

Description:
------------
When using "foreach" on inexisting node, a new node is create.

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

$xml = simplexml_load_string('<root><a>Node a</a></root>');

foreach( $xml->b as $b );

echo $xml->asXML();

?>

Expected result:
----------------
<?xml version="1.0"?>
<root><a>Node a</a></root>

Actual result:
--------------
<?xml version="1.0"?>
<root><a>Node a</a><b/></root>


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


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


Thread (7 messages)

« previous php.bugs (#103594) next »