I am using PHP Domdocument to load my html. In my HTML, I have class="smalllist" two times. But, I need to load the first class elements.
Now, My PHP Code is
$d = new DOMDocument();
$d->validateOnParse = true;
@$d->loadHTML($html);
$xpath = new DOMXPath($d);
$table = $xpath->query('//ul[@class="smalllist"]');
foreach ($table as $row) {
echo $row->getElementsByTagName('a')->item(0)->nodeValue."-";
echo $row->getElementsByTagName('a')->item(1)->nodeValue."
";
}
which loads both the classes. But, I need to load only one class with that name. Please help me in this. Thanks in advance.