title: How do I get the updated HTML from Symfony's DomCrawler component?
body: <p>I'm using Symfony's DomCrawler component. I have it successfully retrieving nodes, adding and amending HTML.</p>
  
  <p>However, I'm not sure how to actually get the HTML out at the end. I'm trying to get the HTML string after it has been changed by DomCrawler, but I can't find out how to do it.</p>
  
  <p>There's no magic <code>__toString()</code> method (and it returns an error when I do <code>print $crawler</code>). There are no <code>get*()</code> methods, no properties with html as a value. I've tried a <code>vardump($crawler)</code> but that doesn't help.</p>
  
  <hr>
  
  <p>UPDATE</p>
  
  <p>If I use</p>
  
  <pre><code>$crawler-&gt;first()-&gt;ownerDocument-&gt;saveHtml()
  </code></pre>
  
  <p>it throws an exception about "calling the saveHtml() on a non-object", plus a PHP error of:</p>
  
  <blockquote>
    <p>Undefined property: Symfony\Component\DomCrawler\Crawler::$ownerDocument</p>
  </blockquote>
  
  <p>I tried using eq(0) instead of first() but get the same error. </p>
  
  <p>However, if I change to using </p>
  
  <pre><code>each( function($node, $i) { 
    print $i . " - " . $node; }
  )
  </code></pre>
  
  <p>then it returns</p>
  
  <pre><code>0 - &lt;html&gt;...&lt;/html&gt;
  </code></pre>