title: How to pretty print XML from the command line?
body: <p>Related: <a href="https://stackoverflow.com/questions/352098/how-to-pretty-print-json-from-the-command-line">How can I pretty-print JSON in (unix) shell script?</a></p>
  
  <p>Is there a (unix) shell script to format XML in human-readable form?</p>
  
  <p>Basically, I want it to transform the following:</p>
  
  <pre><code>&lt;root&gt;&lt;foo a="b"&gt;lorem&lt;/foo&gt;&lt;bar value="ipsum" /&gt;&lt;/root&gt;
  </code></pre>
  
  <p>... into something like this:</p>
  
  <pre><code>&lt;root&gt;
      &lt;foo a="b"&gt;lorem&lt;/foo&gt;
      &lt;bar value="ipsum" /&gt;
  &lt;/root&gt;
  </code></pre>