Bu deneyin:
foreach($html->find('[class=hello]') as $found)
Bu işe yaramazsa, her zaman bu daha az zarif ama hala çalışıyor yaklaşım yapabiliriz:
foreach($html->find('.hello') as $found)
{
if ($found->class != 'hello')
continue;
//do stuff here
}
Sen How to find HTML elements? kılavuzda diyor başlığı altında şeyler bu tür hakkında daha fazla bilgi bulabilirsiniz. Özellik seçiciler çok güçlü, buraya bakın:
[attribute] Matches elements that have the specified attribute.
[attribute=value] Matches elements that have the specified attribute with a certain value.
[attribute!=value] Matches elements that don't have the specified attribute with a certain value.
[attribute^=value] Matches elements that have the specified attribute and it starts with a certain value.
[attribute$=value] Matches elements that have the specified attribute and it ends with a certain value.
[attribute*=value] Matches elements that have the specified attribute and it contains a certain value.