2017-02-15 55 views
0

我想通过XDocument加载RSS源。 网址是:XDocument负载 - 无法打开

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

XDocument doc = XDocument.Load(url); 

但我发现了一个错误:

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

的错误信息是很清楚的:'URI参数必须是文件系统的相对或绝对path'它不可能是一个HTTP URL bu文件路径 –

+0

@Cieja,我没有注意到核心标签。你是正确的,XmlTextReader不存在。如果有一个核心兼容的替代品可以做到这一点。我删除了我的答案,以避免混淆。 – dazedandconfused

+0

有asp.net-core标签。 – Cieja

回答

1

XDocument.Load作为documentation表示不采取URL的,只是文件。

尝试像下面的代码,我完全没测试:

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()); 
}