title: PHP DOM generated XML break line
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/8615422/php-xml-how-to-output-nice-format">PHP XML how to output nice format</a>  </p>
  </blockquote>
  
  
  
  <p>I have the following PHP DOM code that creates a XML document in a dynamic way:</p>
  
  <pre><code>&lt;?php
  
  // create doctype
  $dom = new DOMDocument("1.0");
  // display document in browser as plain text
  // for readability purposes
  header("Content-Type: text/plain");
  
  for ($i=1;$i&lt;=5;$i++)
  {
  // create root element
  $root = $dom-&gt;createElement("toppings");
  $dom-&gt;appendChild($root);
  // create child element
  $item = $dom-&gt;createElement("item");
  $root-&gt;appendChild($item);
  // create text node
  $text = $dom-&gt;createTextNode("pepperoni");
  $item-&gt;appendChild($text);
  }
  // save and display tree
  echo $dom-&gt;saveXML();
  ?&gt;
  </code></pre>
  
  <p>The PHP code generates the next XML code:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;toppings&gt;&lt;item&gt;pepperoni&lt;/item&gt;&lt;/toppings&gt;
  &lt;toppings&gt;&lt;item&gt;pepperoni&lt;/item&gt;&lt;/toppings&gt;
  &lt;toppings&gt;&lt;item&gt;pepperoni&lt;/item&gt;&lt;/toppings&gt;
  &lt;toppings&gt;&lt;item&gt;pepperoni&lt;/item&gt;&lt;/toppings&gt;
  &lt;toppings&gt;&lt;item&gt;pepperoni&lt;/item&gt;&lt;/toppings&gt; 
  </code></pre>
  
  <p>I would like to know what to change in order for the XML look like this other way:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;toppings&gt;
    &lt;item&gt;pepperoni&lt;/item&gt;
  &lt;/toppings&gt;
  &lt;toppings&gt;
    &lt;item&gt;pepperoni&lt;/item&gt;
  &lt;/toppings&gt;
  &lt;toppings&gt;
    &lt;item&gt;pepperoni&lt;/item&gt;
  &lt;/toppings&gt;
  &lt;toppings&gt;
    &lt;item&gt;pepperoni&lt;/item&gt;
  &lt;/toppings&gt;
  &lt;toppings&gt;
    &lt;item&gt;pepperoni&lt;/item&gt;
  &lt;/toppings&gt; 
  </code></pre>