国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學(xué)院 > 開發(fā)設(shè)計 > 正文

HtmlEntities

2019-11-17 02:32:51
字體:
供稿:網(wǎng)友

HtmlEntities

#region GetOnlyTextFromHtmlCode + RemoveHtmlChars + RemoveTagFromHtmlCode        /// <summary>        /// http://www.codePRoject.com/script/Content/ViewAssociatedFile.aspx?rzp=%2FKB%2Fedit%2FZetaHtmlEditControl%2F%2FZetaHtmlEditControl-Source.zip&zep=Control%2FHtmlEditControl.cs&obid=43954&obtid=2&ovid=13        /// </summary>        /// <param name="htmlCode"></param>        /// <returns></returns>        private static string getOnlyTextFromHtmlCode(string htmlCode)        {            //<br>            htmlCode = htmlCode.Replace("/r/n", @" ");            htmlCode = htmlCode.Replace("/r", @" ");            htmlCode = htmlCode.Replace("/n", @" ");            htmlCode = htmlCode.Replace(@"</p>", Environment.NewLine + Environment.NewLine);            htmlCode = htmlCode.Replace(@"</P>", Environment.NewLine + Environment.NewLine);            //html comment             htmlCode = Regex.Replace(                htmlCode,                @"<!--.*?-->",                string.Empty,                RegexOptions.Singleline | RegexOptions.IgnoreCase);            //<p>            htmlCode = Regex.Replace(htmlCode,                @"<br[^>]*>",                Environment.NewLine,                RegexOptions.Singleline | RegexOptions.IgnoreCase);            //tags            htmlCode = removeTagFromHtmlCode(@"style", htmlCode);            htmlCode = removeTagFromHtmlCode(@"script", htmlCode);            //html            htmlCode = Regex.Replace(                htmlCode,                "<(.|/n)+?>",                string.Empty,                RegexOptions.Singleline | RegexOptions.IgnoreCase);            //umlaute            htmlCode = unescapeHtmlEntities(htmlCode);            //whitespaces            htmlCode = Regex.Replace(                htmlCode,                @" +",                @" ",                RegexOptions.Singleline | RegexOptions.IgnoreCase);            return htmlCode;        }        /// <summary>        /// http://dev.w3.org/html5/html-author/charref        /// </summary>        /// <param name="htmlCode"></param>        /// <returns></returns>        private static string unescapeHtmlEntities(string htmlCode)        {

      htmlCode = htmlCode.Replace(@"&nbsp;", @" ");

      htmlCode = htmlCode.Replace(@"&Auml;", @"ä");       htmlCode = htmlCode.Replace(@"&absp;", @"");       htmlCode = htmlCode.Replace(@"&obsp;", @"");       htmlCode = htmlCode.Replace(@"&Obsp;", @"");       htmlCode = htmlCode.Replace(@"&ubsp;", @"");       htmlCode = htmlCode.Replace(@"&Ubsp;", @"");       htmlCode = htmlCode.Replace(@"&szlig;", @"ß");

      htmlCode = htmlCode.Replace(@"&pound;", @"£");       htmlCode = htmlCode.Replace(@"&sect;", @"§");       htmlCode = htmlCode.Replace(@"&copy;", @"©");       htmlCode = htmlCode.Replace(@"&reg;", @"®");       htmlCode = htmlCode.Replace(@"&micro;", @"µ");       htmlCode = htmlCode.Replace(@"&para;", @"¶");       htmlCode = htmlCode.Replace(@"&Oslash;", @"Ø");       htmlCode = htmlCode.Replace(@"&oslash;", @"Ø");       htmlCode = htmlCode.Replace(@"&divide;", @"÷");       htmlCode = htmlCode.Replace(@"&times;", @"×");

            return htmlCode;        }        private static string removeTagFromHtmlCode(            string tag,            string htmlCode)        {            return Regex.Replace(                htmlCode,                string.Format(@"<{0}.*?</{1}>", tag, tag),                string.Empty,                RegexOptions.Singleline | RegexOptions.IgnoreCase);        }        #endregion

  


發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 梨树县| 弥勒县| 涪陵区| 蚌埠市| 朝阳市| 平舆县| 博罗县| 普宁市| 蓬溪县| 巴中市| 安丘市| 鄂伦春自治旗| 黄骅市| 磐石市| 皮山县| 廉江市| 乾安县| 阿图什市| 得荣县| 福鼎市| 曲靖市| 西青区| 固安县| 泌阳县| 鹤峰县| 辉南县| 吴堡县| 上杭县| 黄梅县| 图木舒克市| 遂川县| 儋州市| 千阳县| 灵武市| 隆德县| 奉新县| 额尔古纳市| 鲁山县| 买车| 崇义县| 莫力|