php
2011-03-11 79 views 1 likes 
1

下面是從我的數據庫表拉的標記。基本上,我想php替換圖像與div

<img src="http://newvision.co.ug/IM/logo_white_big.gif" width="80" style="background-color:white;padding:1px"> 

<div style='background:url(http://newvision.co.ug/IM/logo_white_big.gif) center center no-repeat;width:40px;height:40px'></div> 

我DNT想要使用正則表達式只是一個HTMLParser的用PHP附帶

<table> 
<tbody> 
    <tr> 
    <td valign="top"><a href="http://newvision.co.ug/PA/8/13/748484" target= 
    "_blank"><img src="http://newvision.co.ug/IM/logo_white_big.gif" width="80" 
    style="background-color:white;padding:1px" /></a></td> 

    <td valign="top"> 
     <table> 
     <tbody> 
      <tr> 
      <td></td> 
      </tr> 

      <tr> 
      <td valign="top"><b><a target="_blank" href= 
      "http://newvision.co.ug/PA/8/13/748484" style="font-size:9pt">The New 
      Vision Online : Holland withholds sh10b over CHOGM</a></b></td> 
      </tr> 

      <tr> 
      <td valign="top"><a href="http://newvision.co.ug/PA/8/13/748484" style= 
      "font-size:8pt;color&lt;img src=&quot;smilies/worry.gif&quot; alt=&quot;worry&quot; /&gt;ilver" 
      target="_blank">http://newvision.co.ug/PA/8/13/748484</a></td> 
      </tr> 

      <tr> 
      <td valign="top" style="font-size:8pt;font-weight:normal">The New Vision 
      is Uganda's leading daily newspaper.</td> 
      </tr> 
     </tbody> 
     </table> 
    </td> 
    </tr> 
</tbody> 

回答

1

沒有解析器來替換圖像與PHP一起發佈,所以使用PHPQuery,這是一種在JQuery中操縱DOM的方式,例如m而不是。這將允許您使用選擇器來輕鬆更換大塊HTML。

+0

如何使用$ doc = new DOMDocument(); $ doc-> loadHTML – 2011-03-11 00:57:40

+1

是的,你可以做到這一點,但PHPQuery將爲您節省很多搜索DOM的痛苦。 – fredley 2011-03-11 00:58:58

+0

那麼,多少我知道使用DOMDocument()。任何人都可以使用domobject來回答問題。 – 2011-03-11 01:01:06

相關問題