943,917 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 7692
  • C# RSS
Jun 29th, 2006
1

A RSS feed reader....

Expand Post »
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)

C# Syntax (Toggle Plain Text)
  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

C# Syntax (Toggle Plain Text)
  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. }
Similar Threads
Reputation Points: 11
Solved Threads: 0
Junior Poster
johnroach1985 is offline Offline
135 posts
since Apr 2004
Jul 3rd, 2006
0

Re: A RSS feed reader....

What are you wanting to do exactly? Specifically, do you have a question regarding a portion of the code?
Team Colleague
Reputation Points: 186
Solved Threads: 147
Cookie... That's it
alc6379 is offline Offline
2,519 posts
since Dec 2003
Jul 4th, 2006
0

Re: A RSS feed reader....

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
Reputation Points: 11
Solved Threads: 0
Junior Poster
johnroach1985 is offline Offline
135 posts
since Apr 2004
May 27th, 2008
0

Re: A RSS feed reader....

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
Reputation Points: 13
Solved Threads: 1
Newbie Poster
o.narasimharao is offline Offline
7 posts
since May 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: Animated gif in picturebox
Next Thread in C# Forum Timeline: GroupBox selection and Winform Clearing





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC