asp.net页面转换为纯文本 [英] asp.net page convert to plain text
本文介绍了asp.net页面转换为纯文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在将我们的recevesms.aspx页转换为纯文本时遇到问题,因为当我们通过短信对关键字"BALANCE"进行响应时,我需要一个错误
"//标题样式正文font-family:" Verdana; font-weight:normal;"
谢谢
Arvind
hi ,
i have problem to convert our recevesms.aspx page in plain text ,because i need when we give response to keyword "BALANCE" through sms we got one error
"html head titleObject reference not set to an instance of an object./title style body font-family:"Verdana";font-weight:normal;"
thanks
Arvind
推荐答案
如果您的意思是删除html标签,请使用以下代码:
If you mean remove html tags, heres some code for you:
public static class HtmlRemoval
{
/// <summary>
/// Remove HTML from string with Regex.
/// </summary>
public static string StripTagsRegex(string source)
{
return Regex.Replace(source, "<.*?>", string.Empty);
}
/// <summary>
/// Compiled regular expression for performance.
/// </summary>
static Regex _htmlRegex = new Regex("<.*?>", RegexOptions.Compiled);
/// <summary>
/// Remove HTML from string with compiled Regex.
/// </summary>
public static string StripTagsRegexCompiled(string source)
{
return _htmlRegex.Replace(source, string.Empty);
}
/// <summary>
/// Remove HTML tags from string using char array.
/// </summary>
public static string StripTagsCharArray(string source)
{
char[] array = new char[source.Length];
int arrayIndex = 0;
bool inside = false;
for (int i = 0; i < source.Length; i++)
{
char let = source[i];
if (let == '<')
{
inside = true;
continue;
}
if (let == '>')
{
inside = false;
continue;
}
if (!inside)
{
array[arrayIndex] = let;
arrayIndex++;
}
}
return new string(array, 0, arrayIndex);
}
}
这篇关于asp.net页面转换为纯文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文