I searched like crazy and didn't find a solution. The problem is simple.
Let's say I have 3 DIVs:
<div class="class1"> <div class="subclass"> TEXT1 </div> </div> <div class="class2"> <div class="subclass"> TEXT2 </div> </div> <div class="class1 class2"> <div class="subclass"> TEXT3 </div> </div>
So very simple. I just want to find TEXT3 that has BOTH class1 and class2. Using plain HTML DOM Parser, I can't get it to work.
Here is what I tried:
foreach($html->find("[class=class1], [class=class2]") as $item) { $items[] = $item->find('.subclass', 0)->plaintext; }
The problem is
find("[class=class1], [class=class2]")
it finds all of them, since the comma is like OR, if I leave the comma, it searches for a nested class2 inside class1. I'm just looking. And ...
EDIT
Thanks to 19greg96, I found out that
div[class=class1 class2]
works, the problem is that he is looking for exactly those two in this order. Let's say i have
<div class="class1 class2"> <div class="subclass"> TEXT3 </div> </div>
then it works and if i have
<div class="class1 class2 class3"> <div class="subclass"> TEXT3 </div> </div>
it works when I put asterix as it searches for a substring:
div[class*=class1 class2]
PROBLEM
I only know that there is class1 and class3, but maybe others are in random order. This still does not work. Any idea how to just search for A and B in any random order? So that
div[class=class1 class3]
working with this example?