一个简单的去除html标签的方法
时间:2010-09-24 来源:少康

1 public string deleteHtml(string strBody)
2 {
3 for (int i = 0; i < Int32.MaxValue; i++)
4 {
5 if (strBody.IndexOf('<') > -1)
6 strBody = strBody.Remove(strBody.IndexOf('<'), strBody.IndexOf('>') - strBody.IndexOf('<') + 1);
7 else
8 break;
9 }
10 return strBody;
11 }
通过遍历尖括号来循环删除HTML标签,对空格及其他转义字符无效。
相关阅读 更多 +