title: How to reformat XML programmatically?
body: <p>I have an XML document on input which is awfully formatted (it's Delphi project file if anyone cares) - inconsistent indenting, empty lines, strings of nodes lumped together:</p>
  
  <pre><code>&lt;BorlandProject&gt;&lt;Delphi.Personality&gt;&lt;Parameters&gt;&lt;Parameters Name="HostApplication"&gt;C:\Some\Path\Filename.exe&lt;/Parameters&gt; &lt;!--etc--&gt; &lt;Excluded_Packages&gt;
  
  
  &lt;/Excluded_Packages&gt;
  </code></pre>
  
  <p>I want to reformat it into something nice. What's the easiest way to do that programmatically, with Win32/COM? If MSXML, how do I go about it?</p>
  
  <p>I'd like to be able to specify indentation unit too (tab/several spaces).</p>
  
  <p>I tried using Delphi's MSXML wrapper TXmlDocument and it does indeed delete the empty lines and indent nodes with tabs, but it does not split lines like this one:</p>
  
  <pre><code>&lt;BorlandProject&gt;&lt;Delphi.Personality&gt;&lt;Parameters&gt;&lt;Parameters Name="HostApplication"&gt;C:\Some\Path\Filename.exe&lt;/Parameters&gt; &lt;!--etc--&gt; &lt;Excluded_Packages&gt;
  </code></pre>