php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #54972 DOMDocument->formatOutput = true does not work when textnodes or cdata are used
Submitted: 2011-06-01 17:53 UTC Modified: 2011-06-01 22:09 UTC
From: giorgio dot liscio at email dot it Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.3.6 OS: Irrelevant
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: giorgio dot liscio at email dot it
New email:
PHP Version: OS:

 

 [2011-06-01 17:53 UTC] giorgio dot liscio at email dot it
Description:
------------
hi,

$doc = new \DOMDocument("1.0","UTF-8");
$doc->formatOutput = true;
$doc->appendChild($root = $doc->createElement("root"));
$root->appendChild($doc->createElement("sub"));
$root->appendChild($doc->createElement("sub"));
$root->appendChild($doc->createElement("sub"));
// uncomment one or both following line(s):
//$root->appendChild($doc->createTextNode("text"));
//$root->appendChild($doc->createCDATASection("text"));
$root->appendChild($doc->createElement("sub"));
$root->appendChild($doc->createElement("sub"));
echo "<xmp>";
echo $doc->saveXML();
echo "</xmp>";


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-06-01 22:09 UTC] dtajchreber@php.net
-Status: Open +Status: Bogus
 [2011-06-01 22:09 UTC] dtajchreber@php.net
The root element can't have CDATA or text per the XML specification.

[1] http://codepad.org/fzi0Nf1e
[2] http://www.w3.org/TR/2006/REC-xml-20060816/#sec-well-formed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Nov 22 17:01:31 2024 UTC