I try to get the result of a span tag like this:
The problem, the span class is often names css "AB" into the html code and I want to get the one span tag with the itemprop ratingvalue, only.
<span class="AB" itemprop='ratingValue'>Count</span>
In php I use generally this code:
$html= file_get_contents('url');
$html = escapeshellarg($html);
$html = nl2br($html);
$dom = new DOMDocument;
$dom->loadHTML($html);
$xpath = new DOMXPath($dom);
$results = $xpath->query("//*[@itemprop='ratingValue']");
if ($results->length > 0) {
echo $review_count_html = $results->item(0)->nodeValue;
}
This code does run generally, but by this request I get no results. Can anybody help me? Thanks a lot.
</div>