Search code examples
phpguzzlegoutte

What is the difference between filterXpath and filter?


I came accorss these when learning Goutte but I don't know how are they different?


Solution

  • filterXPath allows you to filter by an XPath expression, while filter allows you to filter by CSS selector. Ex:

    $crawler = $crawler->filterXPath('descendant-or-self::body/p');
    $crawler = $crawler->filter('body > p');