title: PHP DomDocument editing all links
body: <p>I am using the following code to grab html from another page and place it into my php page:</p>
  
  <pre><code>$doc = new DomDocument;
  
  // We need to validate our document before refering to the id
  $doc-&gt;validateOnParse = true;
  $doc-&gt;loadHtml(file_get_contents('{URL IS HERE}'));
  $content = $doc-&gt;getElementById('form2');
  
  echo $doc-&gt;SaveHTML($content);
  </code></pre>
  
  <p>I want to change all instances of <code>&lt;a href="/somepath/file.htm"&gt;</code> so that I can prepend to it the actual domain instead.  How can I do this?</p>
  
  <p>So, it would need to change them to:  <code>&lt;a href="http://mydomain.com/somepath/file.htm"&gt;</code> instead.</p>