我正在使用 xpath<br />从以下代码中删除节点,
$nodeList = $xpath->query("//p[node()[1][self::br]]/br[1] | //p[node()[last()][self::br]]/br[last()] | //*[node()[last()][self::br]]/br[last()]");
foreach($nodeList as $node)
{
$node->parentNode->removeChild($node);
}
所以它删除<p>Text<strong><br /></strong></p>了<p>Text</p>哪个是完美的。
但我不希望它从中删除<br />,<p>Text<strong>Bold<br /></strong>Break</p>因为<br />.
我怎样才能解决这个问题?