|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-07-09 03:07 UTC] c00lways at gmail dot com
Description:
------------
when:
domdocument->preserveWhiteSpace = false;
domdocument->formatoutput( true );
...
domdocument->savexml( domelement );
does not have formatoutput effect on savexml( domelement )
the output string is only 1 line...
Reproduce code:
---------------
$dom = new DomDocument("1.0", "iso-8859-1");
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$domme = $dom->createElement( "xx" );
$domme->appendChild(new DOMElement("subxx"));
//try to force, but still same output
$domme->preserveWhiteSpace = false;
$domme->formatOutput = true;
$dom->appendChild( $domme );
return $dom->saveXML( $domme );
Expected result:
----------------
<xx>
<subxx />
</xx>
Actual result:
--------------
<xx><subxx /></xx>
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 06 22:00:01 2025 UTC |
No, still not working: example code: $dom = new DomDocument(); $dom->preserveWhiteSpace = false; $dom->formatOutput = true; $xdom = $dom->createElement( "yyy", "yyyy value" ); $xdom->preserveWhiteSpace = false; $xdom->formatOutput = true; $xchild = $dom->createElement( "OOO", "ooo value" ); $xdom->appendChild( $xchild ); $dom->appendChild( $xdom ); echo $dom->saveXML( $xdom );is this still bogus? it's weird, even without parameter in it, i still get non-formated output $dom = new DomDocument(); $dom->preserveWhiteSpace = true; $dom->formatOutput = false; $xdom = $dom->createElement( "yyy" ); $xchild = $dom->createElement( "OOO" ); $xchild2 = $dom->createElement( "subchild2" ); $xchild3 = $dom->createElement( "subchild3", "sub3" ); $xchild4 = $dom->createElement( "subchild4", "sub4" ); $xchild5 = $dom->createElement( "subchild5" ); $xchild2->setAttribute( "width", 200 ); $xchild2->appendChild( $xchild3 ); $xchild2->appendChild( $xchild4 ); $xchild2->appendChild( $xchild5 ); $xchild->appendChild( $xchild2 ); $xdom->appendChild( $xchild ); $dom->appendChild( $xdom ); echo $dom->saveXML( );