0

The goal is to make some modifications to an HTML document. I load an HTML document in the following way:

    $html5 = new \HTML5();
    $dom = $html5->loadHTML($content);
    $crawler = new Crawler($dom);

I managed to delete nodes I don't need, but I can't figure it out, how to insert html content to inside some tag.

In the example below I'm trying to insert data into head section, but HTML document doesn't change.

    $crawler->filter('head')->each(function (Crawler $crawler, $i) use ($baseUrl) {
        $crawler->addHtmlContent('<base href="' . $baseUrl . '" />');
    });

What do I do wrong here?

Thanks

makeze
  • 55
  • 1
  • 1
  • 10

0 Answers0