日期:2014-05-17  浏览次数:20413 次

查询出来的数据有文本和图片,怎么才能只显示文本内容不显示图片
如:查询出来的数据是
<table cellspacing="0" cellpadding="0" border="0" style="width: 714px; height: 86px;">  
<tbody>  
<tr>  
<td valign="top"><br /> 
asdasdsadasdsadsa<br />
asdsdasdadsdsddsadasdasdasdsa
<img width="309" height="46" src="/website/UpFile/image/box_1.png" alt="" /></td>  
</tr>  
</tbody>  
</table>

怎么才能中显示
<table cellspacing="0" cellpadding="0" border="0" style="width: 714px; height: 86px;">  
<tbody>  
<tr>  
<td valign="top"><br /> 
asdasdsadasdsadsa<br />
asdsdasdadsdsddsadasdasdasdsa
</td>  
</tr>  
</tbody>  
</table>

将其中的图片不显示出来
<img width="309" height="46" src="/website/UpFile/image/box_1.png" alt="" />

------解决方案--------------------
C# code
    protected void Page_Load(object sender, EventArgs e)
    {
        StringBuilder sb = new StringBuilder();
        sb.Append("<table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" style=\"width: 714px; height: 86px;\">");
        sb.Append("<tbody>");
        sb.Append("<tr>");
        sb.Append("<td valign=\"top\"><br />");
        sb.Append("asdasdsadasdsadsa<br />");
        sb.Append("asdsdasdadsdsddsadasdasdasdsa");
        sb.Append("<img width=\"309\" height=\"46\" src=\"/website/UpFile/image/box_1.png\" alt=\"\" /></td>");
        sb.Append("</tr>");
        sb.Append("</tbody>");
        sb.Append("</table>");
        string pattern = @"(?is)<img\s*[^>]*>";
        System.Text.RegularExpressions.Regex reg = new System.Text.RegularExpressions.Regex(pattern);
        string result = reg.Replace(sb.ToString(), "");
    }