From:             bigben3333 at gmail dot com
Operating system: Linux
PHP version:      5.2.6
PHP Bug Type:     DOM XML related
Bug description:  DOMElement removeChild don't work properly

Description:
------------
When i try to delete <li> nodes by removeChild, it delete the </li> too
and i think it's anormal.

If i add a space before the a tag, there is no problem.

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

$html = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd";>
<html><body>
<ul>
        <li><a href="link1.php">ITEM 1</a></li>
        <li><a href="link2.php">ITEM 2</a></li> 
</ul>
</body></html>';


$doc = new DOMDocument();
$doc->loadHTML($html);

while ($nd = $doc->getElementsByTagName('a')->item(0))
        $nd->parentNode->removeChild($nd);      


echo $doc->saveHTML();

Expected result:
----------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd";>
<html><body>
<ul>
        <li></li>
        <li></li>
</ul>
</body></html>

Actual result:
--------------
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/REC-html40/loose.dtd";>
<html><body>
<ul>
        <li>
        <li>
</ul>
</body></html>

-- 
Edit bug report at http://bugs.php.net/?id=45315&edit=1
-- 
Try a CVS snapshot (PHP 5.2): 
http://bugs.php.net/fix.php?id=45315&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): 
http://bugs.php.net/fix.php?id=45315&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=45315&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=45315&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=45315&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=45315&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=45315&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=45315&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=45315&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=45315&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=45315&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=45315&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=45315&r=globals
PHP 4 support discontinued:   http://bugs.php.net/fix.php?id=45315&r=php4
Daylight Savings:             http://bugs.php.net/fix.php?id=45315&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=45315&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=45315&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=45315&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=45315&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=45315&r=mysqlcfg

Reply via email to