Reputation: 2103
I have this script in Symfony 2:
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\DomCrawler\Crawler;
class MyController extends Controller
{
....
foreach($crawler->filter('[type="text/css"]') as $content){
/* make things */
}
foreach($crawler->filter('[rel="stylesheet"]') as $content){
/* make things */
}
¿can $crawler->filter
accept various conditions and do it in one foreach? For example:
foreach($crawler->filter('[rel="stylesheet"] OR [type="text/css"]') as $content){
/* make things */
}
Upvotes: 1
Views: 2303
Reputation: 7606
The filter function takes a standard CSS selector, so:
foreach ($crawler->filter('[rel="stylesheet"],[type="text/css"]') as $content) {
/* make things */
}
Should do the job.
Upvotes: 2
Reputation: 440
AFAIK this is not possible but you can do this:
$crawler->filter('[rel="stylesheet"]')->addAll($crawler->filter('[type="text/css"]'));
This should resolve your problem.
Additionaly, you can also filter with xpath.
Upvotes: 0