phpsymfonydomdomcrawler

Symfony - DomCrawler get element by custom attribute


I need filter this tag

<div dir=3D"ltr">

I tried it

$crawler = $crawler->filter('div[dir=3D"ltr"]');

But not work...

Expected "]", but <identifier "D" at 6> found.

Any ideas?


Solution

  • You're trying to work with data that is quoted-printable encoded. You need to decode the data before treating it like HTML. PHP has the built-in function quoted_printable_decode() to do this for you.

    $html = quoted_printable_decode($html);
    $crawler = new Crawler($html);
    $crawler = $crawler->filter('div[dir="ltr"]');