Regex

M

Maya

Hello,

Im trying to retrieve a text between the <body> and </body> tags in an
HTML file using this code:

public string ReadContentsFromPage(string sb)
{
Regex S = new Regex(@"<BODY>(.*)</BODY>",
RegexOptions.Multiline | RegexOptions.IgnoreCase |
RegexOptions.Compiled);
Match m = S.Match(sb);

string contents = m.Groups[1].Value;
return contents;
}

But the above code return nothing, i tried to remove other nested tags
in the <body> </body> tags and it worked, any idea how to modify the
code to return words inside <body> tags execluding other nested tags?

Thanks,

Maya.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top