File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -1628,6 +1628,9 @@ PHP_FUNCTION(dom_document_savexml)
1628
1628
1629
1629
doc_props = dom_get_doc_props (intern -> document );
1630
1630
format = doc_props -> formatoutput ;
1631
+ if (format ) {
1632
+ options = options | XML_SAVE_FORMAT ;
1633
+ }
1631
1634
1632
1635
buf = xmlBufferCreate ();
1633
1636
if (!buf ) {
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ DOM Document: saveXML with createElement and formatOutput
3
+ --CREDITS--
4
+ CHU Zhaowei <jhdxr@php.net>
5
+ --SKIPIF--
6
+ <?php require_once ('skipif.inc ' ); ?>
7
+ --FILE--
8
+ <?php
9
+ $ dom = new domDocument ('1.0 ' , 'UTF-8 ' );
10
+ $ dom ->formatOutput = true ;
11
+
12
+ $ root = $ dom ->createElement ('root ' );
13
+ $ dom ->appendChild ($ root );
14
+
15
+ $ child1 = $ dom ->createElement ('testsuite ' );
16
+ $ root ->appendChild ($ child1 );
17
+
18
+ $ child11 = $ dom ->createElement ('testcase ' );
19
+ $ child11 ->setAttribute ('name ' , 'leaf1 ' );
20
+ $ child12 = $ dom ->createElement ('testcase ' );
21
+ $ child12 ->setAttribute ('name ' , 'leaf2 ' );
22
+ $ child1 ->appendChild ($ child11 );
23
+ $ child1 ->appendChild ($ child12 );
24
+
25
+ echo $ dom ->saveXml ();
26
+ --EXPECT --
27
+ <? xml version="1.0 " encoding="UTF -8 "?>
28
+ <root>
29
+ <testsuite>
30
+ <testcase name="leaf1"/>
31
+ <testcase name="leaf2"/>
32
+ </testsuite>
33
+ </root>
You can’t perform that action at this time.
0 commit comments