Php 如何使用简单dom html删除子元素
我想删除这个html中带有子选择器的th4,该选择器不带id/classPhp 如何使用简单dom html删除子元素,php,simple-html-dom,Php,Simple Html Dom,我想删除这个html中带有子选择器的th4,该选择器不带id/class <tr> <th>some text</th> <th>some text</th> <th>some text</th> <th>some text</th> <th>some text</th> <th>some text</th> &l
<tr>
<th>some text</th>
<th>some text</th>
<th>some text</th>
<th>some text</th>
<th>some text</th>
<th>some text</th>
<th>some text</th>
<th>some text</th>
</tr>
一些文本
一些文本
一些文本
一些文本
一些文本
一些文本
一些文本
一些文本
将$tr
作为您正在使用的行,您可以使用以下选项选择子项:
$fourthTh = $tr->children(4)
然后,可以在父元素上使用以下命令删除子元素:
$tr->removeChild($fourthTh)
您可以使用jquery来实现这一点,就像使用PHP简单的HTMLDOM一样