使用本机DOM
$dom = new DOMdocument;$dom->loadHTML($htmlString);$xPath = new DOMXPath($dom);$nodes = $xPath->query('//*[@id="anotherDiv"]');if($nodes->item(0)) { $nodes->item(0)->parentNode->removeChild($nodes->item(0));}echo $dom->saveHTML();
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)