Reputation: 3823
I'm trying to download an entire HTML page like following:
var html = new WebClient().DownloadString("http://mypage.com/");
and this HTML document contains a class like this:
<span class="mem_loc">United States</span>
Like this literally...
I need to find somehow now this class mem_loc and it's value , which is United states or any other country...
Is there any "easy" way that this could be done in C# ?
P.S. The structure of the Tag is always like this , so I can probably search it through the string or somehow?
P.S. I want to fetch only whats between > < values, which is a country name...
Upvotes: 1
Views: 2099
Reputation: 1039130
One way to achieve this is to use an HTML parser. For example HTML agility pack
is one such tool. It allows you to do this:
var result = doc.DocumentNode.SelectNodes("//span[@class='mem_loc']"));
Upvotes: 3