php
2011-03-11 84 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

相关问题