title: Making XHTML file valid using regex
body: <p>I'm trying to use PHP with SimpleXML to parse an XHTML file, however the file contains &lt; and > signs which are not part of the markup and cause parsing to fail (opening and end tag mismatches).</p>
  
  <p>How can I convert these to HTML entities before parsing without changing the file or affecting the markup?</p>
  
  <p>Example:</p>
  
  <pre><code>&lt;p&gt; a &lt; b &lt;/p&gt;
  </code></pre>
  
  <p>Would become:</p>
  
  <pre><code>&lt;p&gt; a &amp;lt; &lt;b&gt; &lt;/p&gt;
  </code></pre>