title: Find and replace string in HTML using PHP DOM Parser
body: <p>How do you find and replace a string in html page using the native PHP DOM Parser? </p>
  
  <p>Example string to find: <code>"the &lt;a href='site.com'&gt;company&lt;/a&gt; has been growing for the past 5 months";</code></p>
  
  <p>The parent is a full HTML page for example and the immediate predecessor of that string can be a <code>&lt;div&gt;</code> or <code>&lt;p&gt;</code> for example.. </p>
  
  <p>There is no id or class to that element. Is it still possible to find and manipulate it ? </p>
  
  <p>There is nothing to identify the string or its immediate predecessor. Only the exact string, i.e. sequence of characters that the $search_string consists of.</p>
  
  <p>Thanks!</p>
  
  <p>EDIT: </p>
  
  <p>$string_to_replace = <code>"the &lt;a href='site.com'&gt;company&lt;/a&gt; has been growing for the past 5 months";</code></p>
  
  <p>$replacement_string = <code>"&lt;span class='someClass'&gt;the &lt;a href='site.com'&gt;company&lt;/a&gt; has been growing for the past 5 months";&lt;/span&gt;</code></p>