转换< img> html标记为纯文本 [英] convert <img> html tag to plain text
本文介绍了转换< img> html标记为纯文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好
i希望将html标签转换为纯文本
但是我仍然遇到< img src =的问题HTTPS:// XXX/>标签转换
任何建议请?
Hi all
i want to convert html tags to plain text
but am still having a problem with <img src="https://XXX"/> tag conversion
any suggestion please ??
推荐答案
只需使用此方法希望它解决您的问题:
Simply use this method hope it solves your problem:
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);
}
称之为:
Call it like:
string convertedString = StripTagsCharArray(strHTML); //strHTML is your string with HTML
>
这篇关于转换< img> html标记为纯文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文