php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #49266 DOMDocument::loadHTMLFile add default Namespace even if it already exists
Submitted: 2009-08-15 12:52 UTC Modified: 2010-04-08 11:13 UTC
Votes:2
Avg. Score:4.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:0 (0.0%)
From: gmblar+php at gmail dot com Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.3.0 OS: MacOSX 10.5.8
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
32 + 22 = ?
Subscribe to this entry?

 
 [2009-08-15 12:52 UTC] 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>


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-08 11:13 UTC] rrichards@php.net
-Status: Open +Status: Bogus
 [2010-04-08 11:13 UTC] rrichards@php.net
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
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 12:01:31 2024 UTC