Symfony DomCrawler: Find element with specific attribute value
I can not follow your problem. Using the current development versions (and also 2.1.0 and 2.2.0 versions) of the two software libraries dom-crawler and css-selector, the example code you provided works just fine considering the following example HTML:
<?phpuse Symfony\Component\DomCrawler\Crawler;// require dependencies here $html = <<<'HTML'<!DOCTYPE html><html> <body> <p class="message">Hello World!</p> <p>Hello Crawler!</p> <div id="product"> <a data-type="bla"> <img src="OK"> </a> </div> </body></html>HTML;$crawler = new Crawler($html);$link = $crawler->filter('#product a[data-type="bla"]');echo var_dump(count($link));var_dump($link->filter('img')->attr('src'));
As you can see this is exactly your code (only a little different but essentially not), which gives the following output verbatim:
int(1)string(2) "OK"
The first output line is the count()
and the second is the src attribute value.
Have you run composer update? Have you double-checked the input?