Bug #52369 [Com]: trying to delete nodes while looping domnodelist do not delete them

From: Date: Mon, 19 Jul 2010 23:11:40 +0000
Subject: Bug #52369 [Com]: trying to delete nodes while looping domnodelist do not delete them
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-152533@lists.php.net to get a copy of this message
Edit report at http://bugs.php.net/bug.php?id=52369&edit=1

 ID:               52369
 Comment by:       giorgio dot liscio at email dot it
 Reported by:      giorgio dot liscio at email dot it
 Summary:          trying to delete nodes while looping domnodelist do
                   not delete them
 Status:           Open
 Type:             Bug
 Package:          DOM XML related
 Operating System: all
 PHP Version:      5.3.2

 New Comment:

not a bug?


Previous Comments:
------------------------------------------------------------------------
[2010-07-18 13:14:54] giorgio dot liscio at email dot it

Description:
------------
hi, as summary says
here is the test code

<?php

	$s = '<div><abc /><abc /><abc /><abc /></div>';
	$a = new DOMDocument(); $a->loadXML($s);
        $els = $a->getElementsByTagName("abc");


	// uncomment those three lines to fix
	//foreach($els as $b)
	//	$els2[]=$b;	
	//$els=$els2;

	
	foreach($els as $el)
		$el->parentNode->removeChild($el);

	echo "<textarea rows=20 cols=50>";
	echo "document element (<div>) should be empty:\n";
	echo $a->saveXML();
	
	?>

uncomment lines to see the expected behavior



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



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


Thread (4 messages)

« previous php.bugs (#152533) next »