I’m using preg_match_all function to grab details on a web page. But problem is it returns exact matches to the given structure.
Example:
<span class="st">Details I want to get</span>
But actually it looks like:
<span class="st"><em>Details </em>I want to <b>get<b></span>
So it returns just a few results that exactly match the above given first code!
I found an article about grabbing & there was a code and is it possible to do this using a code like this because I found this working with above structure?
$nodes = $xPath->query('//span[@class="st"]');
foreach($nodes as $node) {
echo $node->nodeValue, PHP_EOL;
}
Use php DOMDocument and strip_tags