diff --git a/ext/dom/document.c b/ext/dom/document.c index 0086d13c413..9250b92700a 100644 --- a/ext/dom/document.c +++ b/ext/dom/document.c @@ -1628,6 +1628,9 @@ PHP_FUNCTION(dom_document_savexml) doc_props = dom_get_doc_props(intern->document); format = doc_props->formatoutput; + if (format) { + options = options | XML_SAVE_FORMAT; + } buf = xmlBufferCreate(); if (!buf) { diff --git a/ext/dom/tests/DOMDocument_savexml_basic2.phpt b/ext/dom/tests/DOMDocument_savexml_basic2.phpt new file mode 100644 index 00000000000..7c010148088 --- /dev/null +++ b/ext/dom/tests/DOMDocument_savexml_basic2.phpt @@ -0,0 +1,33 @@ +--TEST-- +DOM Document: saveXML with createElement and formatOutput +--CREDITS-- +CHU Zhaowei +--SKIPIF-- + +--FILE-- +formatOutput = true; + +$root = $dom->createElement('root'); +$dom->appendChild($root); + +$child1 = $dom->createElement('testsuite'); +$root->appendChild($child1); + +$child11 = $dom->createElement('testcase'); +$child11->setAttribute('name', 'leaf1'); +$child12 = $dom->createElement('testcase'); +$child12->setAttribute('name', 'leaf2'); +$child1->appendChild($child11); +$child1->appendChild($child12); + +echo $dom->saveXml(); +--EXPECT-- + + + + + + + \ No newline at end of file