loadHTML($html); libxml_clear_errors(); // Create a new DOMXPath object $xpath = new DOMXPath($dom); $span = $xpath->query('//span[@data-test-id="price-current-price"]'); //$span1 = $xpath->query('//span[@data-bind="markupText:\'currentPriceAfterPoint\'"]'); // Check if the span element exists if ($span->length > 0) { $hb1= $span->item(0)->nodeValue; } //if ($span->length > 0) { //$hbprice1 = $span[0]->nodeValue; //$hbprice1 = str_replace(".", "", $hbprice1); //$hbprice2 = $span1[0]->nodeValue; //$hb1 = $hbprice1.".".$hbprice2; //$hb1 = $hbprice1; //echo "Value of : $hb1"; else { echo "Span element not found"; }