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;