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

 ID:               49266
 Updated by:       rricha...@php.net
 Reported by:      gmblar+php at gmail dot com
 Summary:          DOMDocument::loadHTMLFile add default Namespace even
                   if it already exists
-Status:           Open
+Status:           Bogus
 Type:             Bug
 Package:          DOM XML related
 Operating System: MacOSX 10.5.8
 PHP Version:      5.3.0

 New Comment:

Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

You are mixing HTML functions (non namespace aware) when loading with
XMl 

functions (which are namespace aware) when saving. Load it via XML
functions since 

its xhtml. HTMl functionality is present for convenience only as DOM is
meant for 

XMl functionality


Previous Comments:
------------------------------------------------------------------------
[2009-08-15 12:52:13] gmblar+php at gmail dot com

Description:
------------
DOMDocument::loadHTMLFile add default Namespace even if it already 

exists

Reproduce code:
---------------
test.html

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>

<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">

        <head>

                <meta http-equiv="Content-Type" content="text/html; 
charset=UTF-8" />

                <title>DOM-Test</title>

        </head>

        <body>

                <p>Hello World</p>

        </body>

</html>





<?php



header('Content-Type: text/plain');

$dom = new DOMDocument();

$dom->formatOutput = true;

$dom->loadHTMLFile('test.html');

echo $dom->saveXML();



?>

Expected result:
----------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>

<html xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">

  <head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" 

/>

    <title>DOM-Test</title>

  </head>

  <body>

    <p>Hello World</p>

  </body>

</html>



Actual result:
--------------
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" 

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";>

<html xmlns="http://www.w3.org/1999/xhtml"; 

xmlns="http://www.w3.org/1999/xhtml"; xml:lang="en" lang="en">

  <head>

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" 

/>

    <title>DOM-Test</title>

  </head>

  <body>

    <p>Hello World</p>

  </body>

</html>




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



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

Reply via email to