开发者

Can I get the matched DOM string with PHP and DOMDocument?

I've got my HTML inside of $html.

dom = new DOMDocument();
$dom->loadHTML($html);


$xpath = new DOMXPath($dom);

$tags = $xpath->query('//div[@id="header"]');


foreach($tags as $tag) 开发者_如何转开发{

    var_dump($tag->nodeValue); // the innerHTML of that element
    var_dump($tag); // object(DOMElement)#3 (0) { }

}

Is there a way to get that node, or remove it?

Basically, I'm parsing an existing website and need to remove elements from it. What method do I call to do that?

Thanks


Have you checked out DOMNode::removeChild ?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜