How To Get Only Plain Text From Html Using C#?
Hi guys. I'm trying to create an app that will find the most frequently used words in the string. In my case, a string is the HTML. I've already can get HTML from URI. For example
Solution 1:
As per This answer, try the following:
var url = "https://www.bbc.com/news/world-middle-east-57327591";
var httpClient = new HttpClient();
var html = await httpClient.GetStringAsync(url);
//Create a regex pattern that selects all html tag elements
string pattern = @"<(.|\n)*?>";
//Replace all tag elements found using that regex with nothing
return Regex.Replace(htmlString, pattern, string.Empty);
Post a Comment for "How To Get Only Plain Text From Html Using C#?"