Excerpt

...content html...

Excerpt

...more content html...

HTML; $crawler = new Crawler($html, 'http://localhost'); // remove all h2 nodes inside .content $crawler->filter('html .content h2')->each(function (Crawler $crawler) { foreach ($crawler as $node) { $node->parentNode->removeChild($node); } }); // output .content nodes with h2 removed $crawler->filter('html .content')->each(function (Crawler $crawler) { echo $crawler->html(); });