mskuratowski
mskuratowski

Reputation: 4124

XDocument Load - cannot open

I'm trying to load rss feed by XDocument. The url is:

http://www.ft.com/rss/home/uk

XDocument doc = XDocument.Load(url);

But I'm getting an error:

Cannot open 'http://www.ft.com/rss/home/uk'. The Uri parameter must be a file system relative or absolute path.

Upvotes: 0

Views: 925

Answers (1)

koelkastfilosoof
koelkastfilosoof

Reputation: 2242

XDocument.Load does not take URL's, only files as stated in the documentation.

Try something like the following code which I totally did not test:

using(var httpclient = new HttpClient())
{
    var response = await httpclient.GetAsync("http://www.ft.com/rss/home/uk");
    var xDoc = XDocument.Load(await response.Content.ReadAsStreamAsync());
}

Upvotes: 1

Related Questions