use Html agility pack to download rss and show elements on a list

c# html-agility-pack rss windows-phone xml


I use the HTML Agility Pack to download from my RSS feed. So far, I've been able to download it correctly and access all the components using SelectNode. However, how can I, for example, list a title that is one node in the item node in a listbox?

I employ this to download rss.

HtmlWeb.LoadAsync("", DownLoadCompleted);

void DownLoadCompleted(object sender, HtmlDocumentLoadCompleted e)
        if (e.Error == null)
            HtmlDocument doc = e.Document;
            if (doc != null)
                foreach (HtmlNode rsstitle1 in doc.DocumentNode.SelectNodes("//title")) 
                    var title = doc.DocumentNode.SelectNodes("//title");

                    if (rsstitle1 != null)
                            string titleText = rsstitle1.InnerText;
                            rsstitle.Text = titleText;

This "rsstitle" element is a textBlock within a listbox called "listBox1" on the main page. I can see the strig titleText in the textblock, but I can only view the final item; it seems to loop through all of the titles in the list of downloaded RSS items to get to the last title. Therefore, I want to know how to create a list of all titles. This is how the RSS xml looks:

<?xml version='1.0' encoding='UTF-8'?>
<rss xmlns:atom='' xmlns:openSearch='' xmlns:blogger='' xmlns:georss='' xmlns:gd='' xmlns:thr='' version='2.0'>
    <lastBuildDate>Fri, 11 Oct 2013 13:24:41 +0000</lastBuildDate>
    <category>suma sumarum</category>
    <title>Windows Phone Novosti</title>
    <description>Prvi Windows Phone blog u Bosni i Hercegovini koji vama donosi sve potrebne informacije za vas omiljeni Windows Phone operativni sistem.</description>
    <managingEditor> (Dino Borogovac)</managingEditor>
      <guid isPermaLink='false'>,</guid>
      <pubDate>Fri, 11 Oct 2013 13:24:00 +0000</pubDate>
      <category domain=''>aplikacije</category>
      <title>Facebook Beta aplikacija sa novom nadogradnjom</title>
      <description>&lt;div align="justify"&gt;&lt;a href=""&gt;&lt;img alt="IMG_2353" border="0" height="447" src="" style="background-image: none; border: 0px currentcolor; display: block; float: none; margin: 0px auto;" title="IMG_2353" width="670" /&gt;&lt;/a&gt;&lt;/div&gt;&lt;div align="justify"&gt;Facebook Beta aplikacija dobila novu nadogradnju, ovo je jedna od rijetkih aplikacija koja se redovno aktualizira sa popravkama, novostima i novim funkcijama. Facebook Beta je aplikacija koja sluzi Microsoft-u za testiranje novih funkcija prije nego sto one izadu u oficijelnu aplikaciju �Facebook�.&lt;/div&gt;&lt;div align="justify"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div align="justify"&gt;U novoj verziji, koja je za WP7 kao i za WP8 Microsoft-ovi razvijaci su napisali da su dodali jos par jezika (prevoda) u aplikaciju i popravili generalno brzinu aplikacije.&lt;/div&gt;&lt;a href=""&gt;&lt;br /&gt;&lt;table class="app-download" summary="Skinite aplikaciju iz ovog clanka"&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;img height="160" src="" style="display: inline;" title="Facebook aplikacija" width="160" /&gt;&lt;/td&gt;&lt;td&gt;&lt;span style="font-size: x-large; font-weight: bold;"&gt;Facebook Beta&lt;/span&gt;&lt;br /&gt;od: Microsoft Corp.&lt;br /&gt;Verzija:;br /&gt;Cijena: Besplatno&lt;br /&gt;&lt;br /&gt;&lt;img src="" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/a&gt;</description>
      <author> (Dino Borogovac)</author>
      <media:thumbnail xmlns:media='' url='' height='72' width='72'/>

There are 25 other components with identical interiors, including title, description, pubdate, and link. I want to possess:

First, the main page has a list of all the titles.

Second, all of the links are tied to their respective titles, so when a user touches on one, it directs them to another page where they may feed the URL to a web browser control.

Third, if you can, add a little description to the title.

Fourth, display the post content that is in the "description" element of the RSS feed that has already been retrieved. Keep the other parts in place since I need things like photos and tables.

10/13/2013 10:19:57 PM

Popular Answer

It is an excellent idea to utilize rather than Agility Pack (which you may use without a doubt). You can parse and work with RSS feeds with the aid of the classes that NET provides. I think you want to create an application similar to an RSS reader. The sites below include several examples that might be helpful to you:

Hope this was useful.

If this resolves your issue, let us know.

10/15/2013 6:00:21 AM

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow