Symfony DomCrawler not returning expected value

624 Views Asked by At

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 Symfony\Component\DomCrawler\Crawler;
    use Masterminds\HTML5;
    
    $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

0

There are 0 best solutions below