ID: 45315 Updated by: [EMAIL PROTECTED] Reported By: bigben3333 at gmail dot com -Status: Open +Status: Bogus Bug Type: DOM XML related Operating System: Linux PHP Version: 5.2.6 New Comment:
use ->saveXML() instead of ->saveHTML() if you want XHTML instead of HTML 4. There is no bug, it's correct behaviour. Previous Comments: ------------------------------------------------------------------------ [2008-06-19 14:04:00] bigben3333 at gmail dot com Error in the bug description : It's when i try to delete <a> node, not <li> node. ------------------------------------------------------------------------ [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
