title: Clear newlines and all unnecessary whitespaces in xml tags
body: <p><strong>I need all XML tags to fit on one line (<em>ie</em> clear newlines)</strong>; if possible, I'd like to clear all other unnecessary whitespaces, but it's less important.  </p>
  
  <p><em>The reason why I need this clearing is:<br>
  I'm using a <code>DOMDocument::schemaValidate()</code> to validate an XML against an XSD schema. The function returns errors with line numbers, and these line numbers don't match the ones numbered in the editor in which I display the results (because the validator ignores the newlines in the tags, and the editor doesn't).</em></p>
  
  <p>I found a lot of questions and answers about matching a string between two specific delimiters using regexp, but not for matching <strong>some</strong> specific characters between the two delimiters. The nearest I found is: <a href="https://stackoverflow.com/questions/6915330/remove-whitespace-from-xml-tags">Remove whitespace from XML tags</a> but I was not able to bring this to work in php. </p>
  
  <p><strong>Example:</strong> given the string:  </p>
  
  <pre><code>&lt;package xmlns="http://www.idpf.org/2007/opf" 
      version=""
      unique-identifier=""
      prefix="optional"
      lang="optional"
      dir="optional"
      id="optional"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.idpf.org/2007/opf http://fpierrat.fr/mvs/epub3-opf.xsd"
  &gt;
  </code></pre>
  
  <p>I need to delete all newlines (and if possible all extra-tabs and extra-spaces) between tagnames and attributes. Output should look like: </p>
  
  <pre><code>&lt;package xmlns="http://www.idpf.org/2007/opf" version="" unique-identifier="" prefix="optional" lang="optional" dir="optional" id="optional" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.idpf.org/2007/opf http://fpierrat.fr/mvs/epub3-opf.xsd" &gt;
  </code></pre>
  
  <p><strong>Only the whitespaces between the enclosing <code>&lt;</code>and <code>&gt;</code> should be affected.</strong> Tag content should remain as is.<br>
  Thanks in advance for your help.</p>