I have a structure like this:
<div>
<span>
<a class="test">one</a>
</span>
<a>two</a>
<a>three</a>
</div>
And here is my code:
$data = $html->find('div', 0);
foreach($data->find('a') as $article){
echo $word .= $article->plaintext."<br>";
}
And here is current result:
one
two
three
And here is expected result:
two
three
As you see in the above result, I want to select all <a>
element except the one that has test
classname. How can I do that?
Note: I use this PHP library.
My suggestion (didn't test it):
$data = $html->find('div', 0);
foreach($data->find('a') as $article){
if($article->getAttribute('class') != 'test'){
echo $word .= $article->plaintext."<br>";
}
}
I did not use this library before, but maybe:
->find('a[class!=test]')-
http://simplehtmldom.sourceforge.net/manual.htm#section_find => attribute filters tab