I have a string in c# MVC controller which is HTML.
eg: <html>...<head>...</head><body>...<div class="someClass">...</div><div class="someClass">...</div><div class="someClass">...</div></body></html>
Now I want to get all values of elements where Class = someClass and place them in a string array. Is this possible without using string manipulation functions? Currently I am using string manipulation like this
string str = above String;
if (str.Contains(@"<div class=""someClass"">"))
{
str = str.Remove(0, str.IndexOf(@"<div class=""someClass"">" + 22));
// add the text in array until </div> and move to next element
I am sure there is a way in c#. Can someone please guide me in the right direction.
Note: That the HTML string is not from File.
Note: This is not a Javascript question. Although I would love to use Javascript in Controller for this one.