#31484 [Opn]: Strage behaviour when looping through a NodeList

From: Date: Tue, 11 Jan 2005 00:56:22 +0000
Subject: #31484 [Opn]: Strage behaviour when looping through a NodeList
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-71799@lists.php.net to get a copy of this message
 ID:               31484
 User updated by:  clynx at users dot sourceforge dot net
 Reported By:      clynx at users dot sourceforge dot net
 Status:           Open
 Bug Type:         DOM XML related
 Operating System: FreeBSD 4.11
 PHP Version:      5.0.3
 New Comment:

updated libxml2 to 2.6.16, same error


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

[2005-01-11 01:30:34] clynx at users dot sourceforge dot net

Description:
------------
I want to use a complete Namespace to execute self written PHP
Classes.
My Parser has some Problems with the way PHP handles the Code.

It seems like my code handles all dom Functions right, but the Result
is not the one I would expect.

Reproduce code:
---------------
<?php
$dom = new DOMDocument();
$dom->load("http://www.succont.de/php/domxml.xml");

$nodelist=$dom->getElementsByTagNameNS( 'http://test.de/test', '*' );
for($i = 0; $i < $nodelist->length; $i++)
{
    $node = $nodelist->item($i);
    if($node->localName == "test")
    {
         $node->parentNode->removeChild($node);
         echo $node->localName . " removed \n";
     } else {
         echo 'handle: ' . $node->localName . "\n";
     }
}
echo "\nXML File:\n".$dom->saveXML();
?>

Expected result:
----------------
bash-2.05a$ php -q test.php
handle: doSomething
test removed
handle: doSomething

XML File:
<?xml version="1.0" encoding="utf-8"?>
<example xmlns:test="http://test.de/test">
        <test:doSomething/>

        <test:doSomething/>
</example>

Actual result:
--------------
bash-2.05a$ php -q test.php
handle: doSomething
test removed

XML File:
<?xml version="1.0" encoding="utf-8"?>
<example xmlns:test="http://test.de/test">
        <test:doSomething/>

        <test:doSomething/>
</example>


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


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


Thread (4 messages)

« previous php.bugs (#71799) next »