I am using the Symfony DomCrawler component. I have successfully retrieving nodes, adding and modifying HTML.
However, I'm not sure how to actually get the HTML at the end. I am trying to get an HTML string after it has been modified using DomCrawler, but I cannot figure out how to do this.
There is no magic __toString() method (and it returns an error when I do print $crawler ). There are no get*() methods, no properties with html as the value. I tried vardump($crawler) , but that does not help.
UPDATE
If i use
$crawler->first()->ownerDocument->saveHtml()
it throws an exception about "calling saveHtml () on a non-object", plus a PHP error:
Undefined property: Symfony \ Component \ DomCrawler \ Crawler :: $ ownerDocument
I tried using eq (0) instead of first (), but getting the same error.
However, if I switch to using
each( function($node, $i) { print $i . " - " . $node; } )
then he returns
0 - <html>...</html>
source share