/ Published in: PHP
Manipulates XML nodes using PHP's Dom library. Includes XPath navigation, child manipulation, and deletion of current document.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function formatIFRAMECells1($oDom) { $oXpath = new DOMXpath($oDom); $oElements = $oXpath->query("//td[@class='tditem']"); //Remove the TD element to the right of the logo cell. This xpath query finds the following TD element: // <td bgcolor="#FFFFFF" height="2" class="tditem"> // // Only remove it if it's also followed by: //<div align="left"><img src="http://www.mobiles4everyone.com/images/horizontallineplain.jpg" width="100%" height="1"></div> { foreach ($oElements as $oElement) { if($oElement->hasChildNodes()) { $oChildren = $oElement->childNodes; for($i=0;$i<$oChildren->length;$i++) { $oChild = $oChildren->item($i); if($oChild->nodeName == "div") { if($oChild->hasChildNodes()) { $oDivChild = $oChild->firstChild; if($oDivChild->nodeName == "img") { $oElement->parentNode->removeChild($oElement); break; } } } } } } } return $oDom; }