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)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Xml;
namespace RSS_Reader
{
public partial class frmMain : Form
{
XmlTextReader rssReader;
XmlDocument rssDoc;
XmlNode nodeRss;
XmlNode nodeChannel;
XmlNode nodeItem;
ListViewItem rowNews;
public frmMain()
{
InitializeComponent();
}
private void btnRead_Click(object sender, EventArgs e)
{
lstNews.Items.Clear();
this.Cursor = Cursors.WaitCursor;
rssReader = new XmlTextReader(txtUrl.Text);
rssDoc = new XmlDocument();
rssDoc.Load(rssReader);
for (int i = 0; i < rssDoc.ChildNodes.Count; i++)
{
if (rssDoc.ChildNodes[i].Name == "rss")
{
nodeRss = rssDoc.ChildNodes[i];
}
}
for (int i = 0; i < nodeRss.ChildNodes.Count; i++)
{
if (nodeRss.ChildNodes[i].Name == "channel")
{
nodeChannel = nodeRss.ChildNodes[i];
}
}
lblTitle.Text = "Title: " + nodeChannel["title"].InnerText;
lblLanguage.Text = "Language: " + nodeChannel["language"].InnerText;
lblLink.Text = "Link: " + nodeChannel["link"].InnerText;
lblDescription.Text = "Description: " + nodeChannel["description"].InnerText;
for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)
{
if (nodeChannel.ChildNodes[i].Name == "item")
{
nodeItem = nodeChannel.ChildNodes[i];
rowNews = new ListViewItem();
rowNews.Text = nodeItem["title"].InnerText;
rowNews.SubItems.Add(nodeItem["link"].InnerText);
lstNews.Items.Add(rowNews);
}
}
this.Cursor = Cursors.Default;
}
private void lstNews_SelectedIndexChanged(object sender, EventArgs e)
{
if (lstNews.SelectedItems.Count == 1)
{
for (int i = 0; i < nodeChannel.ChildNodes.Count; i++)
{
if (nodeChannel.ChildNodes[i].Name == "item")
{
nodeItem = nodeChannel.ChildNodes[i];
if (nodeItem["title"].InnerText == lstNews.SelectedItems[0].Text)
{
txtContent.Text = nodeItem["description"].InnerText;
break;
}
}
}
}
}
private void lstNews_DoubleClick(object sender, EventArgs e)
{
System.Diagnostics.Process.Start(lstNews.SelectedItems[0].SubItems[1].Text);
}
}
}
program.cs part of the code
using System;
using System.Collections.Generic;
using System.Windows.Forms;
namespace RSS_Reader
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.Run(new frmMain());
}
}