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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
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

Add a Patch

Pull Requests

Add a Pull Request

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: Thu Apr 25 13:01:30 2024 UTC