1--TEST--
2XML Serialization formatting
3--EXTENSIONS--
4dom
5--FILE--
6<?php
7
8$tests = [
9    '<root></root>',
10    '<root> </root>',
11    '<!DOCTYPE html><html><head/></html>',
12    '<root><child>text</child><!-- comment --><foo>&amp;</foo></root>',
13    '<root><child>text</child><![CDATA[x]]><foo><bar/></foo></root>',
14    '<root><a/><foo><bar><?foo <x><y/></x> ?><baz/></bar></foo></root>',
15    <<<XML
16    <root>
17      <child>
18        <child/>
19      </child>
20    </root>
21    XML,
22];
23
24foreach ($tests as $test) {
25    echo "---\n";
26    $dom = Dom\XMLDocument::createFromString($test);
27    $dom->formatOutput = true;
28    echo $dom->saveXml(), "\n";
29}
30
31?>
32--EXPECT--
33---
34<?xml version="1.0" encoding="UTF-8"?>
35<root/>
36---
37<?xml version="1.0" encoding="UTF-8"?>
38<root> </root>
39---
40<?xml version="1.0" encoding="UTF-8"?>
41<!DOCTYPE html>
42<html>
43  <head/>
44</html>
45---
46<?xml version="1.0" encoding="UTF-8"?>
47<root>
48  <child>text</child>
49  <!-- comment -->
50  <foo>&amp;</foo>
51</root>
52---
53<?xml version="1.0" encoding="UTF-8"?>
54<root><child>text</child><![CDATA[x]]><foo><bar/></foo></root>
55---
56<?xml version="1.0" encoding="UTF-8"?>
57<root>
58  <a/>
59  <foo>
60    <bar>
61      <?foo <x><y/></x> ?>
62      <baz/>
63    </bar>
64  </foo>
65</root>
66---
67<?xml version="1.0" encoding="UTF-8"?>
68<root>
69  <child>
70    <child/>
71  </child>
72</root>
73