[英]How to remove a child element with simple dom html
我想使用沒有 id/class 的PHP Simple HTML DOM 的子選擇器刪除此 html 中的第 4 個
<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)
然后,您可以在父元素上使用DOMNode::removeChild()
刪除子元素:
$tr->removeChild($fourthTh)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.