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

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

Question

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("http://www.wpnovosti.com/feeds/posts/default?alt=rss", 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;
                            //MessageBox.Show(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='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0' version='2.0'>
  <channel>
    <atom:id>tag:blogger.com,1999:blog-6139395842965860280</atom:id>
    <lastBuildDate>Fri, 11 Oct 2013 13:24:41 +0000</lastBuildDate>
    <category>suma sumarum</category>
    <category>osnove</category>
    <category>glasine</category>
    <category>novosti</category>
    <category>uredaji</category>
    <category>aplikacije</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>
    <link>http://www.wpnovosti.com/</link>
    <managingEditor>noreply@blogger.com (Dino Borogovac)</managingEditor>
    <generator>Blogger</generator>
    <openSearch:totalResults>451</openSearch:totalResults>
    <openSearch:startIndex>1</openSearch:startIndex>
    <openSearch:itemsPerPage>25</openSearch:itemsPerPage>
    <item>
      <guid isPermaLink='false'>tag:blogger.com,1999:blog-6139395842965860280.post-226671981499881807</guid>
      <pubDate>Fri, 11 Oct 2013 13:24:00 +0000</pubDate>
      <atom:updated>2013-10-11T15:24:41.780+02:00</atom:updated>
      <category domain='http://www.blogger.com/atom/ns#'>aplikacije</category>
      <title>Facebook Beta aplikacija sa novom nadogradnjom</title>
      <description>&lt;div align="justify"&gt;&lt;a href="http://lh4.ggpht.com/-kEftfu0aP-M/Ulf7tRs3EMI/AAAAAAAAIlo/bgmYMjOUSAg/s1600-h/IMG_2353%25255B3%25255D.jpg"&gt;&lt;img alt="IMG_2353" border="0" height="447" src="http://lh6.ggpht.com/-vomeApNFLA0/Ulf7uXzNw3I/AAAAAAAAIlw/sDhV-TsAqM8/IMG_2353_thumb.jpg?imgmax=800" 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="http://windowsphone.com/s?appid=93da5d29-daf0-4783-9ed5-a87b33247ec6"&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="http://3.bp.blogspot.com/-eCEJytrvw6Y/UlAhObc2mMI/AAAAAAAAIiY/DlnS17mqNwE/s1600/617e6c4c-6b9f-4903-b67d-dcd71062a3e5.png" 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: 5.1.1.1&lt;br /&gt;Cijena: Besplatno&lt;br /&gt;&lt;br /&gt;&lt;img src="http://2.bp.blogspot.com/-wKPKvNDpPww/Uc2-U6TAYFI/AAAAAAAAHow/yNwU7HrY3jg/s241/WPS_Download_Badge+bosanski+finish.png" /&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/a&gt;</description>
      <link>http://www.wpnovosti.com/2013/10/facebook-beta-aplikacija-sa-novom.html</link>
      <author>noreply@blogger.com (Dino Borogovac)</author>
      <media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://lh6.ggpht.com/-vomeApNFLA0/Ulf7uXzNw3I/AAAAAAAAIlw/sDhV-TsAqM8/s72-c/IMG_2353_thumb.jpg?imgmax=800' height='72' width='72'/>
      <thr:total>0</thr:total>
    </item>

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.

1
0
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:

http://code.msdn.microsoft.com/wpapps/RSS-Reader-in-Windows-afa86457http://mobile.dzone.com/articles/build-rss-reader-windows-phone

Hope this was useful.

If this resolves your issue, let us know.

0
10/15/2013 6:00:21 AM


Related Questions





Related

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