I am using this below code to get the elements that are in special HTML element :
$dom = new DOMDocument();
@$dom->loadHTML($google_html);
$xpath = new DOMXPath($dom);
$tags = $xpath->query('//span[@class="st"]');
foreach ($tags as $tag) {
echo $node_value;
}
Now, the problem is that, the code gives all of the elements that are in one special class, but i just need to get the First item that has that class name.
So i don't need using foreach
loops.
How to use that code to get JUST the FIRST item ?