title: Pretty Print XML with Line Wrap
body: <p>I am interested in reflowing an XML file. I can use <code>xmllint --format my.xml</code> but it only does indentation. I have some very long lines that looks like:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;Server port=&quot;8005&quot; shutdown=&quot;SHUTDOWN&quot;&gt;
    &lt;Listener className=&quot;org.apache.catalina.startup.VersionLoggerListener&quot;/&gt;
    &lt;Service name=&quot;Catalina&quot;&gt;
      &lt;ConnectorX acceptCount=&quot;100&quot; bindOnInit=&quot;false&quot; connectionTimeout=&quot;20000&quot; 
  disableUploadTimeout=&quot;true&quot; enableLookups=&quot;false&quot; maxHttpHeaderSize=&quot;8192&quot; 
  maxThreads=&quot;200&quot; minSpareThreads=&quot;25&quot; port=&quot;8081&quot; protocol=&quot;HTTP/1.1&quot; 
  redirectPort=&quot;8443&quot;/&gt;
    &lt;/Service&gt;
  &lt;/Server&gt;
  </code></pre>
  <p>Is there a utility that can recognize page width along with the indentation so I can get output that indents long line wrap like:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  &lt;Server port=&quot;8005&quot; shutdown=&quot;SHUTDOWN&quot;&gt;
    &lt;Listener className=&quot;org.apache.catalina.startup.VersionLoggerListener&quot;/&gt;
    &lt;Service name=&quot;Catalina&quot;&gt;
      &lt;ConnectorX acceptCount=&quot;100&quot; bindOnInit=&quot;false&quot; connectionTimeout=&quot;20000&quot; 
        disableUploadTimeout=&quot;true&quot; enableLookups=&quot;false&quot; maxHttpHeaderSize=&quot;8192&quot; 
        maxThreads=&quot;200&quot; minSpareThreads=&quot;25&quot; port=&quot;8081&quot; protocol=&quot;HTTP/1.1&quot; 
        redirectPort=&quot;8443&quot;/&gt;
    &lt;/Service&gt;
  &lt;/Server&gt;
  </code></pre>
  <p>I would prefer something that is built-in to linux, but am open to other suggestions.</p>
  <p>As an aside, I am working within Ansible, so if there is a solution within that environment, that would work as well.</p>