【发布时间】:2011-12-02 12:23:25
【问题描述】:
我正在将数据从 1 个数据库导入到另一个。我被要求删除所有 HTML 内容,因为它混乱且无效,只保留链接
我目前使用以下 VB.NET 函数从内容字符串中去除所有 HTML 标记:
Public Shared Function StripHTML(ByVal htmlString As String) As String
Dim pattern As String = "<(.|\n)*?>"
Return Regex.Replace(htmlString, pattern, String.Empty)
End Function
我正在寻找一种从内容中去除所有标签的方法,但 a(锚)标签。
例如,如果我有以下 HTML 内容:
<table>
<tr>
<td>
Lorem <a href="http://google.com">Ipsum</a>
</td>
</tr>
</table>
这将简单地变成:
Lorem <a href="http://google.com">Ipsum</a>
我该怎么做?
【问题讨论】:
-
你能给我们更多关于你的任务的信息吗?你想达到什么目的?
-
我正在将数据从 1 个数据库导入到另一个数据库。我被要求删除所有 HTML 内容,因为它混乱且无效,只保留链接
标签: asp.net vb.net anchor strip-tags