A RSS feed reader....

Please support our C# advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Apr 2004
Posts: 129
Reputation: johnroach1985 is an unknown quantity at this point 
Solved Threads: 0
johnroach1985's Avatar
johnroach1985 johnroach1985 is offline Offline
Junior Poster

A RSS feed reader....

 
0
  #1
Jun 29th, 2006
Hiya people been working on a new project.You guessed right a RSS reader for podcasts....I have been able to reach and read text from a sample code I found.But because I am quite a noob I couldn't figured it out how to work it for podcasts...
Here is the code: (Note that I'm currently using .net 2005 and the code you are seeing is the form code...thanks in advance)

  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Text;
  7. using System.Windows.Forms;
  8. using System.IO;
  9. using System.Xml;
  10.  
  11. namespace RSS_Reader
  12. {
  13. public partial class frmMain : Form
  14. {
  15. XmlTextReader rssReader;
  16. XmlDocument rssDoc;
  17. XmlNode nodeRss;
  18. XmlNode nodeChannel;
  19. XmlNode nodeItem;
  20. ListViewItem rowNews;
  21. public frmMain()
  22. {
  23. InitializeComponent();
  24. }
  25.  
  26. private void btnRead_Click(object sender, EventArgs e)
  27. {
  28. lstNews.Items.Clear();
  29. this.Cursor = Cursors.WaitCursor;
  30.  
  31. rssReader = new XmlTextReader(txtUrl.Text);
  32. rssDoc = new XmlDocument();
  33.  
  34. rssDoc.Load(rssReader);
  35.  
  36.  
  37. for (int i = 0; i < rssDoc.ChildNodes.Count; i++)
  38. {
  39.  
  40. if (rssDoc.ChildNodes[i].Name == "rss")
  41. {
  42.  
  43. nodeRss = rssDoc.ChildNodes[i];
  44. }
  45. }
  46.  
  47. for (int i = 0; i < nodeRss.ChildNodes.Count; i++)
  48. {
  49.  
  50. if (nodeRss.ChildNodes[i].Name == "channel")
  51. {
  52.  
  53. nodeChannel = nodeRss.ChildNodes[i];
  54. }
  55. }
  56.  
  57.  
  58. lblTitle.Text = "Title: " + nodeChannel["title"].InnerText;
  59. lblLanguage.Text = "Language: " + nodeChannel["language"].InnerText;
  60. lblLink.Text = "Link: " + nodeChannel["link"].InnerText;
  61. lblDescription.Text = "Description: " + nodeChannel["description"].InnerText;
  62.  
  63.  
  64. for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)
  65. {
  66.  
  67. if (nodeChannel.ChildNodes[i].Name == "item")
  68. {
  69. nodeItem = nodeChannel.ChildNodes[i];
  70.  
  71.  
  72. rowNews = new ListViewItem();
  73. rowNews.Text = nodeItem["title"].InnerText;
  74. rowNews.SubItems.Add(nodeItem["link"].InnerText);
  75. lstNews.Items.Add(rowNews);
  76. }
  77. }
  78.  
  79. this.Cursor = Cursors.Default;
  80. }
  81.  
  82. private void lstNews_SelectedIndexChanged(object sender, EventArgs e)
  83. {
  84.  
  85. if (lstNews.SelectedItems.Count == 1)
  86. {
  87.  
  88. for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)
  89. {
  90.  
  91. if (nodeChannel.ChildNodes[i].Name == "item")
  92. {
  93.  
  94. nodeItem = nodeChannel.ChildNodes[i];
  95.  
  96. if (nodeItem["title"].InnerText == lstNews.SelectedItems[0].Text)
  97. {
  98.  
  99. txtContent.Text = nodeItem["description"].InnerText;
  100.  
  101. break;
  102. }
  103. }
  104. }
  105. }
  106. }
  107.  
  108. private void lstNews_DoubleClick(object sender, EventArgs e)
  109. {
  110.  
  111. System.Diagnostics.Process.Start(lstNews.SelectedItems[0].SubItems[1].Text);
  112. }
  113. }
  114. }
program.cs part of the code

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Windows.Forms;
  4.  
  5. namespace RSS_Reader
  6. {
  7. static class Program
  8. {
  9. /// <summary>
  10. /// The main entry point for the application.
  11. /// </summary>
  12. [STAThread]
  13. static void Main()
  14. {
  15. Application.EnableVisualStyles();
  16. Application.Run(new frmMain());
  17. }
  18. }
"By the data to date, there is only one animal in the Galaxy dangerous to man—man himself. So he must supply his own indispensable competition. He has no enemy to help him."
From Time Enough for Love by Robert A. Heinlein
Reply With Quote Quick reply to this message  
Join Date: Dec 2003
Posts: 2,414
Reputation: alc6379 has a spectacular aura about alc6379 has a spectacular aura about alc6379 has a spectacular aura about 
Solved Threads: 123
Team Colleague
alc6379's Avatar
alc6379 alc6379 is offline Offline
Cookie... That's it

Re: A RSS feed reader....

 
0
  #2
Jul 3rd, 2006
What are you wanting to do exactly? Specifically, do you have a question regarding a portion of the code?
Alex Cavnar, aka alc6379
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 129
Reputation: johnroach1985 is an unknown quantity at this point 
Solved Threads: 0
johnroach1985's Avatar
johnroach1985 johnroach1985 is offline Offline
Junior Poster

Re: A RSS feed reader....

 
0
  #3
Jul 4th, 2006
Yes I need to know how can I make the above RSS feed reader to work for Podcasts.....So when I double click I can download my favourite programs
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 7
Reputation: o.narasimharao is an unknown quantity at this point 
Solved Threads: 1
o.narasimharao o.narasimharao is offline Offline
Newbie Poster

Re: A RSS feed reader....

 
0
  #4
May 27th, 2008
I am getting Remote name should not be resolved while loading the xmldoc at
rssDoc = new XmlDocument();

rssDoc.Load(rssReader);

pls help me
thanx in advance
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum


Views: 5068 | Replies: 3
Thread Tools Search this Thread



Tag cloud for C#
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC