Bug #62259 [Opn->Nab]: Additional xml declaration added to document when calling save

From: Date: Tue, 03 Dec 2013 09:56:11 +0000
Subject: Bug #62259 [Opn->Nab]: Additional xml declaration added to document when calling save
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-183094@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=62259&edit=1 ID: 62259 Updated by: mike@php.net Reported by: andreas dot a dot sandberg at gmail dot com Summary: Additional xml declaration added to document when calling save -Status: Open +Status: Not a bug Type: Bug Package: DOM XML related Operating System: Ubuntu PHP Version: 5.3.13 Block user comment: N Private report: N New Comment: loadHTML loads HTML4. XHTML must be valid XML, so you have to load it with loadXML. Previous Comments: ------------------------------------------------------------------------ [2012-06-08 06:08:56] andreas dot a dot sandberg at gmail dot com Description: ------------ It appears an extra xml declaration can get added as part of the output when calling saveXML on a DOMDocument that was loaded by calling loadHTML. Not sure how common of a use case this is but I load by xhtml doc using the loadHTML call as it is more forgiving and the content I'm loading already has the xml declaration. Of course I can remove it but not sure if this is the intended behavior. Test script: --------------- $xml = '<?xml version="1.0" encoding="utf-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html><head></head><body></body></html>'; $dom = new DOMDocument(); $dom->loadHTML($xml); $out = $dom->saveXML(null); echo $out; Expected result: ---------------- <?xml version="1.0" standalone="yes"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html><head/><body/></html> Actual result: -------------- <?xml version="1.0" standalone="yes"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <?xml version="1.0" encoding="utf-8" standalone="no"??> <html><head/><body/></html> ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=62259&edit=1

« previous php.bugs (#183094) next »