Reputation: 149
I have html like this :
<h3><span itemprop="name">ABC</span> XYZ</h3>
I used xpath but it only get the text in span tag (ABC) , now i want to get text after span . Ex: I want to get XYZ
Here is my code :
string = mb_convert_encoding($string, 'HTML-ENTITIES', "UTF-8");
$dom = new DOMDocument();
@$dom->loadHTML($string);
$xpath = new DOMXPath( $dom );
$nodelist = $xpath->query( "//h3/span[@itemprop='name']/text()" );
return $nodelist->item(0)->nodeValue;
And ressult is : ABC
Upvotes: 1
Views: 1980