Bug #54972 [Opn->Bgs]: DOMDocument->formatOutput = true does not work when textnodes or cdata are used
Edit report at http://bugs.php.net/bug.php?id=54972&edit=1
ID: 54972
Updated by: dtajchreber@php.net
Reported by: giorgio dot liscio at email dot it
Summary: DOMDocument->formatOutput = true does not work when
textnodes or cdata are used
-Status: Open
+Status: Bogus
Type: Bug
Package: DOM XML related
Operating System: Irrelevant
PHP Version: 5.3.6
Block user comment: N
Private report: N
New Comment:
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
Previous Comments:
------------------------------------------------------------------------
[2011-06-01 17:53:32] 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>";
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/bug.php?id=54972&edit=1
Thread (2 messages)