如何使用简单的html-dom删除html中的元素


how to delete the elements in html using simple html dom?

我正在尝试,但不起作用

 include_once('simple_html_dom.php');
             $handle = file_get_html('file name.php');
             if (!empty($handle)) {
             $ret = $handle->find('div', 0);//this is able to find the element
             echo $ret;
             $ret->outertext = '';//this is **NOT** deleting the video

outertext='';不工作,我不知道为什么

我试过$handle->find('div[id="'.$i.'"]', 0)->outertext = ''; ,但也没用。

还有其他我没有尝试过的方法吗??

我不明白为什么这会有什么不同,但请尝试在查找的同时进行修改。

$handle->find('div', 0)->outertext = '';