How to scrape xml file using htmlagilitypack

asp.net c# html-agility-pack screen-scraping

Question

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

Accepted Answer

Try using RSS library instead of the HtmlAgilityPack:

Here are some links that might help you:


Popular Answer

The error says that the value is null. So there is too possibly's

select new
         {
                LinkURL = info.InnerText??string.Empty,
                Content = content.InnerText??string.Empty,

         };

or in the aspx. I think that it should be minus in the string like this:

<%# Eval("LinkURL")??string.Empty %>+"-"+<%# Eval("Text")??string.Empty %> 



Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why