$mystring="This is mystring. <a href='http://www.google.com'>Google.</a>";
$dom = new DOMDocument;
$dom->loadHTML($mystring);
$xPath = new DOMXPath($dom);
$nodes = $xPath->query('//a');
if($nodes->item(0)) {
$nodes->item(0)->parentNode->removeChild($nodes->item(0));
}
echo $dom->saveHTML();
I want to get output:
This is mystring. Google.
But i got just:
This is mystring.