C # How to remove the UL and Li in the specified label text method

Source: Internet
Author: User
This article mainly describes the C # removal of UL Li in the specified label text method, involving C # for the page HTML elements for regular matching and replacement of the relevant operation skills, the need for friends can refer to the next

The example in this article describes how C # removes the text from the specified label in UL Li. Share to everyone for your reference, as follows:

Now the demand is becoming more and more perverted, but the code can only be as satisfying as possible, here first to deduct the text in the hyperlinks in UL and 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> "; Here MatchCollection mctable = regex.matches (prompthtml, SS); foreach (Match mtable in mctable) {  if (mtable.success) c1/>{    prompthtml = mtable.groups[2]. Value;}  } resulthtml = prompthtml;

The specific data sources are as follows:

The code is as follows:

<ul><li><a href= "http://localhost/tg.aspx?ID=4194" rel= "external nofollow" > which theme funds are expected to erupt? </a></li></ul>

This is the clip to the UL and Li in the span inside the text:

middlebannerhtml = Getdata.gethttpinfo (Config.middlebanner_url, "Utf-8"); middlebannerhtml = Middlebannerhtml.replace ("<ul><li>", ""); middlebannerhtml = Middlebannerhtml.replace ("</li>< /ul> "," "); string ss = @" <span> ([^<]+) </span> "; Here MatchCollection mctable = regex.matches (middlebannerhtml, SS); foreach (Match mtable in mctable) {  if ( mtable.success)  {    middlebannerhtml = mtable.groups[1]. Value;}  } Middlecontent = middlebannerhtml;

The specific data sources are as follows:

The code is as follows:

<ul><li><span>3 Year 5 times times the increase is not just stock oh ~</span> <a href= " http://localhost/tg.aspx?ID=4195 "rel=" external nofollow "> View </a></li></ul> now; 
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.