title: Format output of $SimpleXML->asXML();
body: <p>The title pretty much says it all.</p>
  
  <p>If I have something like (from PHP site examples):</p>
  
  <pre><code>$xmlstr = &lt;&lt;&lt;XML
  &lt;?xml version='1.0' standalone='yes'?&gt;
  &lt;movies&gt;&lt;/movies&gt;
  XML;
  
  $sxe = new SimpleXMLElement($xmlstr);
  
  $sxe-&gt;addAttribute('type', 'documentary');
  
  $movie = $sxe-&gt;addChild('movie');
  $movie-&gt;addChild('title', 'PHP2: More Parser Stories');
  $movie-&gt;addChild('plot', 'This is all about the people who make it work.');
  
  $characters = $movie-&gt;addChild('characters');
  $character  = $characters-&gt;addChild('character');
  $character-&gt;addChild('name', 'Mr. Parser');
  $character-&gt;addChild('actor', 'John Doe');
  
  $rating = $movie-&gt;addChild('rating', '5');
  $rating-&gt;addAttribute('type', 'stars');
  
  
  echo("&lt;pre&gt;".htmlspecialchars($sxe-&gt;asXML())."&lt;/pre&gt;");
  
  die();
  </code></pre>
  
  <p>I end up outputing a long string like so:</p>
  
  <pre><code>&lt;?xml version="1.0" standalone="yes"?&gt;
  &lt;movies type="documentary"&gt;&lt;movie&gt;&lt;title&gt;PHP2: More Parser Stories&lt;/title&gt;&lt;plot&gt;This is all about the people who make it work.&lt;/plot&gt;&lt;characters&gt;&lt;character&gt;&lt;name&gt;Mr. Parser&lt;/name&gt;&lt;actor&gt;John Doe&lt;/actor&gt;&lt;/character&gt;&lt;/characters&gt;&lt;rating type="stars"&gt;5&lt;/rating&gt;&lt;/movie&gt;&lt;/movies&gt;
  </code></pre>
  
  <p>This is fine for a program consumer, but for debugging/human tasks, does anyone know how to get this into a nice indented format?</p>