如何使用htmlagilitypack刮xml文件 [英] How to scrape xml file using htmlagilitypack
问题描述
我需要从 http://feeds.feedburner.com/Torrentfreak 抓取xml文件
我使用这个代码:
var webGet = new HtmlWeb();
var document = webGet.Load(http://feeds.feedburner.com/TechCrunch);
var TechCrunch = from document.DocumentNode.SelectNodes(// channel)中的信息
来自info.SelectNodes中的链接(// guid [@ isPermaLink ='false'])
来自info.SelectNodes(// description)的内容
select new
{
LinkURL = info.InnerText,
Content = content.InnerText,
};
lvLinks.DataSource = TechCrunch;
lvLinks.DataBind();
我已经在列表视图控件中使用它在asp.net页面上显示。
使用
<%#Eval(LinkURL)%> - <%#Eval(文字)%>
但显示错误
>值不能为null。
参数名称:source
有什么问题?是否有可能使用HtmlAgilityPack来抓取(获取)xml节点数据?
请建议
感谢
尝试使用RSS库而不是HtmlAgilityPack:
以下链接可能会对您有所帮助:
- http://www.rssdotnet.com/
- http://www.yetanotherchris.me/home/2010/2/8 /simplified-c-atom-and-rss-feed-parser.html
I need to scrape an xml file from http://feeds.feedburner.com/Torrentfreak for its links and description.
I used this code :
var webGet = new HtmlWeb();
var document = webGet.Load("http://feeds.feedburner.com/TechCrunch");
var TechCrunch = from info in document.DocumentNode.SelectNodes("//channel")
from link in info.SelectNodes("//guid[@isPermaLink='false']")
from content in info.SelectNodes("//description")
select new
{
LinkURL = info.InnerText,
Content = content.InnerText,
};
lvLinks.DataSource = TechCrunch;
lvLinks.DataBind();
I have used this in list view control to show on asp.net page. using
<%# Eval("LinkURL") %> - <%# Eval("Text") %>
But its showing error
Value cannot be null. Parameter name: source
what's the problem ? And is it possible to scrape (fetch) xml nodes data using HtmlAgilityPack ? Please suggest Thanks
Try using RSS library instead of the HtmlAgilityPack:
Here are some links that might help you:
- http://www.rssdotnet.com/
- http://www.yetanotherchris.me/home/2010/2/8/simplified-c-atom-and-rss-feed-parser.html
这篇关于如何使用htmlagilitypack刮xml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!