Symfony DomCrawler not returning expected value

  domcrawler, php, symfony

The example is pretty simple. I am trying to experiment with the Symfony’s DomCrawler and trying to get the download section of the official PHP page https://www.php.net/ :

    <?php
    
    require __DIR__.'/../vendor/autoload.php';
    use SymfonyComponentDomCrawlerCrawler;
    use MastermindsHTML5;
    
    $url = 'https://www.php.net/';
    $content = file_get_contents($url);
    
    
    $crawler = new Crawler($content);
    $item = $crawler->filterXPath("/html/body/div[2]/div/div/div[2]");
    dd($item);

But dd($item) returns the same as dd($crawler), as if the filterXpath() didn’t make anything. Am i missing something? I would expect $item to have something like "'< div >divcontent< /div >’".

$item

Source: Symfony Questions

LEAVE A COMMENT