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

From: Date: Tue, 11 Jan 2005 00:30:35 +0000
Subject: #31484 [NEW]: Strage behaviour when looping through a NodeList
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-71796@lists.php.net to get a copy of this message
From:             clynx at users dot sourceforge dot net
Operating system: FreeBSD 4.11
PHP version:      5.0.3
PHP Bug Type:     DOM XML related
Bug description:  Strage behaviour when looping through a NodeList

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 bug report at http://bugs.php.net/?id=31484&edit=1
-- 
Try a CVS snapshot (php4):   http://bugs.php.net/fix.php?id=31484&r=trysnapshot4
Try a CVS snapshot (php5.0): http://bugs.php.net/fix.php?id=31484&r=trysnapshot50
Try a CVS snapshot (php5.1): http://bugs.php.net/fix.php?id=31484&r=trysnapshot51
Fixed in CVS:                http://bugs.php.net/fix.php?id=31484&r=fixedcvs
Fixed in release:            http://bugs.php.net/fix.php?id=31484&r=alreadyfixed
Need backtrace:              http://bugs.php.net/fix.php?id=31484&r=needtrace
Need Reproduce Script:       http://bugs.php.net/fix.php?id=31484&r=needscript
Try newer version:           http://bugs.php.net/fix.php?id=31484&r=oldversion
Not developer issue:         http://bugs.php.net/fix.php?id=31484&r=support
Expected behavior:           http://bugs.php.net/fix.php?id=31484&r=notwrong
Not enough info:             http://bugs.php.net/fix.php?id=31484&r=notenoughinfo
Submitted twice:             http://bugs.php.net/fix.php?id=31484&r=submittedtwice
register_globals:            http://bugs.php.net/fix.php?id=31484&r=globals
PHP 3 support discontinued:  http://bugs.php.net/fix.php?id=31484&r=php3
Daylight Savings:            http://bugs.php.net/fix.php?id=31484&r=dst
IIS Stability:               http://bugs.php.net/fix.php?id=31484&r=isapi
Install GNU Sed:             http://bugs.php.net/fix.php?id=31484&r=gnused
Floating point limitations:  http://bugs.php.net/fix.php?id=31484&r=float
No Zend Extensions:          http://bugs.php.net/fix.php?id=31484&r=nozend
MySQL Configuration Error:   http://bugs.php.net/fix.php?id=31484&r=mysqlcfg


Thread (4 messages)

« previous php.bugs (#71796) next »