Here is a solution, that delivers new and filled SyndicationFeed object for/from the given RSS url:
var feedUrl = @"http://jobs.huskyenergy.com/RSS";
try
{
var webClient = new WebClient();
// hide ;-)
webClient.Headers.Add ("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");
// fetch feed as string
var content = webClient.OpenRead(feedUrl);
var contentReader = new StreamReader(content);
var rssFeedAsString = contentReader.ReadToEnd();
// convert feed to XML using LINQ to XML and finally create new XmlReader object
var feed = SyndicationFeed.Load(XDocument.Parse(rssFeedAsString).CreateReader());
// take the info from the firdst feed entry
var firstFeedItem = feed.Items.FirstOrDefault();
Console.WriteLine(firstFeedItem.Title.Text);
Console.WriteLine(firstFeedItem.Links.FirstOrDefault().Uri.AbsoluteUri);
}
catch (Exception exception)
{
Console.WriteLine(exception.Message);
}
The site processes apparently only calls from "browsers" so disguise the code resp. the call as one. The result is:
Summer Student UEO Regulatory & Environment Strategy - (Calgary, AB)
http://jobs.huskyenergy.com/ca/alberta/student/jobid4444904-summer-student-ueo-regulatory--environment-strategy-jobs
The WebClient class supports also asynchronous operations with events and tasks, so there is no problem to make the reader non blocking.
The explanation for the html problem is following: the site changed something and/or they are somehow not allowing automated feeds (anymore). The html message comes from the service interruption message. I tried to access the service (using LINQ to XML with LINQPad, don't wonder about the Dump function):
var feedUrl = @"http://jobs.huskyenergy.com/RSS";
var feedContent = XDocument.Load(feedUrl);
feedContent.Dump();
//var feed = SyndicationFeed.Load(feedContent.CreateReader());
//feed.Dump();
and got this answer:
<!DOCTYPE html []>
<!--[if IE 7]><html lang="en" prefix="og: http://ogp.me/ns#" class="non-js lt-ie9 lt-ie8"><![endif]-->
<!--[if IE 8]><html lang="en" prefix="og: http://ogp.me/ns#" class="non-js lt-ie9"><![endif]-->
<!--[if gt IE 8]><!-->
<html lang="en" prefix="og: http://ogp.me/ns#" class="non-js">
<!--<![endif]-->
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>
Service Interruption
</title>
<link rel="stylesheet" href="http://seostatic.tmp.com/SiteOutage/style.css" />
</head>
<body>
<p id="outageMessage">This system is currently experiencing a service interruption. <br />We apologize for any inconvenience.</p>
</body>
</html>
So html element revealed. :-) The site looks just fine when opened in a browser and this means the XmlReader resp. LINQ to XML is working correctly.