本帖最后由 imtns59521 于 2013-04-01 14:34:34 编辑

解决方案 »

  1.   

    用正则表达式匹配        #region 去除HTML标记
            /// <summary>        
            /// 去除HTML标记        
            /// </summary>        
            /// <param name="Htmlstring">包括HTML的源码 </param>        
            /// <returns>已经去除后的文字</returns>        
            public static string NoHTML(object Htmlstring)
            {
                string html = Htmlstring.ToString();
                if (string.IsNullOrEmpty(html) == true)
                { return ""; }
                string temp = Regex.Replace(html, "<[^>]*>", "", RegexOptions.Compiled);
                return temp.Replace("&nbsp;", " ");
            }
            #endregion
      

  2.   


                    string str = @"&lt;div&gt;&lt;div style=&quot;font-family:微软雅黑; font-size:16px; word-wrap: break-word;width:756px&quot;&gt;2012 昨天下雨了。&lt;/div&gt;&lt;div style=&quot; margin-left:120px&quot;&gt;&lt;img src=&quot;images/Events/成长历程_321.jpg&quot; /&gt;&lt;/div&gt;&lt;/div&gt;&lt;div&gt;&lt;div style=&quot;font-family:微软雅黑; font-size:16px; word-wrap: break-word;width:756px&quot;&gt;2012 今天是个好天气。&lt;/div&gt;&lt;div style=&quot; margin-left:120px&quot;&gt;&lt;img src=&quot;images/Events/成长历程_321.jpg&quot; /&gt;&lt;/div&gt;&lt;/div&gt;";
                    str = Server.HtmlDecode(str);
                    str = System.Text.RegularExpressions.Regex.Replace(str, @"<[^>]*>", string.Empty, System.Text.RegularExpressions.RegexOptions.IgnoreCase);
                    Response.Write(str);
                    Response.End();