I'm using following code for extracting the contents from a div with this format: <div id="post-contents"></div>
string findtext2 = @"<div[^>]*\\id=\post-contents\[^>]*>(.*?)</div>";
string myregex2 = txt;
MatchCollection doregex2 = Regex.Matches(myregex2, findtext2);
string matches2 = "";
foreach (Match match2 in doregex2)
{
matches2 = (matches2 + (match2.ToString()));
}
return matches2;
But I got some errors with HTML tags. Actually the tag contains some other HTML tags as follow:
<div id="post-contents"><p dir="ltr">HI HI HI</p></div>
May you please help me how can I get just <p dir="ltr">HI HI HI</p>
?
Thank you