|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #47137 LIBXML_NOXMLDECL is not working anymore
Submitted: 2009-01-17 13:58 UTC Modified: 2009-02-03 14:45 UTC
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: romain dot lalaut at laposte dot net Assigned:
Status: Not a bug Package: XML related
PHP Version: 5.3.0alpha3 OS: Linux
Private report: No CVE-ID: None
 [2009-01-17 13:58 UTC] romain dot lalaut at laposte dot net
It seems that saving a DOMDocument which is loaded with LIBXML_NOXMLDECL doesn't avoid to get the xml declaration.
It is a big problem to produce a xhtml document for internet because  IE6 is not dead yet.

Tested with libxml2 2.6.32 and 2.7.2

Reproduce code:
$xml = '<myxml/>';

$doc = new DOMDocument();
$doc->loadXml($xml, LIBXML_NOXMLDECL);

echo $doc->saveXML();

Expected result:

Actual result:
<?xml version="1.0"?>


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-02-03 14:45 UTC]
That is a save option which hasn't yet been implemented so has never 
 [2010-05-28 03:45 UTC] jpatokal at iki dot fi
This is not "bogus" at all.  See

  LIBXML_NOXMLDECL  ( integer )
    Drop the XML declaration when saving a document 

From that, I'd expect saveXML to drop the XML declaration as promised, but it does not, so it's broken.  See also
 [2011-08-11 10:31 UTC] suit at rebell dot at
It is stoll not fixed and its very annoying, if you want to create XML documents without declaration. Bug #50989 works for me, but its still no satisfying solution.

Fix this either in PHP or at least in the Documentation.
 [2013-09-23 11:10 UTC] joscha at feth dot com
Is there any update on this issue?
 [2013-12-12 15:38 UTC] avillalbacasas at gmail dot com
Is there any update about this issue? If it doesn't work, and it will not work, please update the documentation since that it is a fake right now.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Sat Jun 25 02:05:45 2022 UTC