php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47666 SaveXML not well formed
Submitted: 2009-03-15 21:23 UTC Modified: 2009-03-19 13:09 UTC
From: info at pcxtra dot nl Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.2.9 OS: Fedora 9
Private report: No CVE-ID: None
 [2009-03-15 21:23 UTC] info at pcxtra dot nl
Description:
------------
SaveXML method generates html element with TWO xmlns attributes (which is not well formed XML).

Reproduce code:
---------------
$html = <<<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">
  <head>
  </head>
  <body>
  </body>
</html>
HTML;

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

$doc2 = new DOMDocument();
$doc2->loadXML( $result );
$result2 = $doc->saveXML();
  
echo $result2;


Expected result:
----------------
The expected result is:
<!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">
  <head>
  </head>
  <body>
  </body>
</html>

Actual result:
--------------
Warning: DOMDocument::loadXML() [function.DOMDocument-loadXML]: Attribute xmlns redefined in Entity, line: 3 in /home/siuser/www/dev/engine/100/test.php on line 21

$result shows two xmlns attributes for the html element:
<!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">
  <head>
  </head>
  <body>
  </body>
</html>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-03-19 13:09 UTC] rrichards@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri May 03 11:01:32 2024 UTC