<p>When I build XML up from scratch with <code>XmlDocument</code>, the <code>OuterXml</code> property already has everything nicely indented with line breaks.  However, if I call <code>LoadXml</code> on some very "compressed" XML (no line breaks or indention) then the output of <code>OuterXml</code> stays that way.  So ...</p>

<p>What is the simplest way to get beautified XML output from an instance of <code>XmlDocument</code>?</p>

As adapted from
Erika Ehrli's
blog, this should do it:
```
```
XmlDocument doc = new XmlDocument();
doc.LoadXml("<item><name>wrench</name></item>");
// Save the document to a file and auto-indent the output.
using (XmlTextWriter writer = new XmlTextWriter("data.xml", null)) {
    writer.Formatting = Formatting.Indented;
    doc.Save(writer);
}
```
```