tags:

views:

84

answers:

3

{Yup, the above more or less explains it} :)

Regex oRegex = new Regex("<body.*?>(.*?)</body>", RegexOptions.Multiline);

The above doesnt seem to work if the body has any attributes in it.

+4  A: 

Don't use a regular expression. Use something that's meant to parse XML/HTML:

XmlDocument.SelectSingleNode("//body").InnerXml;

Load your string into an XmlDocument, use the SelectSingleNode function (which takes an XPath expression as a parameter), then extract what you need from the resulting XmlNode.

Welbog
See my edit above
Stephen
+5  A: 

With the HTML Agility Pack (assuming it is html, not xhtml):

HtmlDocument doc = new HtmlDocument();
doc.LoadHtml(html);
string body = doc.DocumentNode.SelectSingleNode("/html/body").InnerHtml;
Marc Gravell
Thanks Marc, i'm gonna try the xmldoc route, and if that fails then go with the agility pack.
Stephen
A: 

I solved it eventually by using RegexOptions.Singleline instead of using RegexOptions.Multiline

Stephen