0
votes

I use html agility pack do download from my rss source, so far i can download it right and i can access all the elements with SelectNode but how can i lets say i have an title in my rss and it is one node in the item node, i can read it but how to list it on a listbox?!

i use this to download the 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" is an element on the mainpage an textBlock inside an listbox names "listBox1", i see the strig titleText in the textblock but i see only the last item, it seems like it circles all the way thru to the last title in the downloaded rss items list. so my question is how can i make an list of all titles. the xml from the rss look like this:

<?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>[email protected] (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>[email protected] (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 another 25 elements wit hall the same inside like title, description, pubdate, and link. i would like to have:

First all the titles in one list in the mainpage.

Second all the links bind to the titles so if the users taps on it so it goes to my other page where is can pass the url to an webbrowser control.

Third if its possible to make an short description under the title

Fourth show the post body which is in the "description" element of the rss already downloaded, and leave the elements like they are on the rss because there are elements like pictures and tables and so on that i need.

1
RSS is XML. Why don't you use XML libraries?Simon Mourier
i wanted to learn how to use HAP for later use and make some parsing that is not strictly tied to RSS. thats the reason.dinchy87

1 Answers

0
votes

Rather than using Agility Pack (which you can use for sure), it is a good idea to use .NET provided classes which can help you to parse and manipulate RSS feeds. I believe, you want to build a RSS reader kind of application. There are lot of samples are following links should help you:

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

Hope this helps.

Let us know if this solves your problem.