如何使用htmlagilitypack刮xml文件 [英] How to scrape xml file using htmlagilitypack

查看:281
本文介绍了如何使用htmlagilitypack刮xml文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从 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:



以下链接可能会对您有所帮助:




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:

这篇关于如何使用htmlagilitypack刮xml文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆