XDocument 加载 - 无法打开 [英] XDocument Load - cannot open
本文介绍了XDocument 加载 - 无法打开的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试通过 XDocument 加载 rss 提要.网址是:
I'm trying to load rss feed by XDocument. The url is:
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.
推荐答案
XDocument.Load
不采用 URL,仅采用 文档.
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());
}
这篇关于XDocument 加载 - 无法打开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文