C#删除UL及LI中指定标签里文字的方法是什么

发布时间:2020-08-29 11:50:02 作者:小新
来源:亿速云 阅读:126

C#删除UL及LI中指定标签里文字的方法是什么?这个问题可能是我们日常学习或工作经常见到的。希望通过这个问题能让你收获颇深。下面是小编给大家带来的参考内容,让我们一起来看看吧!

现在需求越来越变态,但是做代码只能尽量满足,这里先是扣去ul和li中的超链接里的文字

PromptHtml = GetData.GetHTTPInfo(Config.Prompt_Url, "utf-8");
PromptHtml = PromptHtml.Replace("<ul><li>", "");
PromptHtml=PromptHtml.Replace("</li></ul>", "");
string ss = @"<a[\s\S]*?href=""([^" rel="external nofollow" "]*?)""[^>]*?>([\s\S]*?)</a>"; //这里
MatchCollection mcTable = Regex.Matches(PromptHtml, ss);
foreach (Match mTable in mcTable)
{
  if (mTable.Success)
  {
    PromptHtml = mTable.Groups[2].Value;
  }
}
resultHtml = PromptHtml;

具体的数据源如下:

代码如下:

<ul><li><a href="http://localhost/tg.aspx?ID=4194" rel="external nofollow" >哪些主题基金有望爆发?</a></li></ul>

这篇是扣去ul和li中的span里面的文字:

middlebannerHtml = GetData.GetHTTPInfo(Config.Middlebanner_Url, "utf-8");
middlebannerHtml = middlebannerHtml.Replace("<ul><li>", "");
middlebannerHtml = middlebannerHtml.Replace("</li></ul>", "");
string ss = @"<span>([^<]+)</span>"; //这里
MatchCollection mcTable = Regex.Matches(middlebannerHtml, ss);
foreach (Match mTable in mcTable)
{
  if (mTable.Success)
  {
    middlebannerHtml = mTable.Groups[1].Value;
  }
}
middleContent = middlebannerHtml;

具体的数据源如下:

代码如下:

<ul><li><span>3年5倍涨幅的 不只是股票哦~</span> <a href="http://localhost/tg.aspx?ID=4195" rel="external nofollow" >立即查看</a></li></ul>

感谢各位的阅读!看完上述内容,你们对C#删除UL及LI中指定标签里文字的方法是什么大概了解了吗?希望文章内容对大家有所帮助。如果想了解更多相关文章内容,欢迎关注亿速云行业资讯频道。

推荐阅读:
  1. css中li标签的属性是什么
  2. Vue.jS的ul-li标签仿select标签是什么

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

上一篇:Kotlin中实现类似Java或C#中静态的方法是什么

下一篇:ASP.NET实现进度条效果的方法是什么

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》