HTML:
<div class="vm-customfield-cart">
<span class="product-field-type-S">Some important text</span><br />
<span class="product-field-type-S">Lorem ipsum dolor</span><br />
</div>
How to remove just span which contains text Lorem ipsum
. Everything after Lorem ipsum
can be variable, thats why i need to search jsut by Lorem ipsum
.
My code looks like:
$dom = new DOMDocument;
$dom->loadHTML($html);
$xp = new DOMXPath($dom);
$spanNodeList = $xp->query("//*[contains(., 'Lorem ipsum')]");
foreach ($spanNodeList as $spanNode) {
//I have no idea how to clean it out
}
End result should looks like:
<div class="vm-customfield-cart">
<span class="product-field-type-S">Some important text</span><br />
</div>