ID:               45315
 User updated by:  bigben3333 at gmail dot com
 Reported By:      bigben3333 at gmail dot com
 Status:           Open
 Bug Type:         DOM XML related
 Operating System: Linux
 PHP Version:      5.2.6
 New Comment:

Error in the bug description : It's when i try to delete <a> node, not
<li> node.


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

[2008-06-19 13:59:52] bigben3333 at gmail dot com

error in the bug description

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

[2008-06-19 13:55:45] bigben3333 at gmail dot com

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 this bug report at http://bugs.php.net/?id=45315&edit=1

Reply via email to