Parsing a PodCast in C#
October 2, 2007
Recently I assimilated the Windows Media Player into one of my projects, today I decided to add PodCast capabilities.
I was surprised how easy this was, I guess I’d expected more of a challenge. I went into this knowing nothing about PodCasts, once I realized it was RSS I knew this would be easy. RSS used to be Rich Site Summary, until people figured out how useful it was and renamed it Really Simple Syndication.
I know this is really simple code, frankly that’s part of why I’m posting it. Simple examples save people time. I tried to find a quick Copy+Paste solution for Podcasts on Google just before I wrote this. After three minutes of searching I quit and spent five writing this.
The example I wrote is a console application (yes, it runs from the DOS prompt) that grabs a Podcast page and loops through all the Podcast listings. I use console apps for examples because there isn’t a lot too them. This helps coders quickly Copy+Paste the code they need from my examples.
So without further adieu, this is how simple it is to do Podcasts in C#…
//This is always included in Console applications.
//This contains the XmlDocument, XmlNodeList and Node objects used below.
static void Main(string args)
//This loads the Podcast
XmlDocument doc = new XmlDocument();
//This builds a list of the Item nodes
XmlNodeList items = doc.SelectNodes(“//item”);
//This loops through the list and writes out the title and URL.
for (int i = 0; i < items.Count; i++)
Click here to download the Visual Studio project.