Parsing RSS (XML)

M

Marc Jennings

Morning All,

I am trying to write a small windows app to keep track of a couple of
blogs. The blogs I want to look at are available as RSS feeds through
a static URL.

A typical feed will look something like this.

<rss version='2.0'>
<channel>
<copyright>Copyright 2002-2004 Blog Author</copyright>
<description>BlogSite description</description>
<link>http://www.example.com</link>
<title>BlogSite Title</title>
<item>
<title>1st Article</title>
<pubDate>2004-07-18 13:47:45</pubDate>
<link>http://www.example.com/bloggers.php?id=365</link>
<description>Synopsis of the article here.</description>
</item>
<item>
<title>2nd Article</title>
<pubDate>2004-07-19 13:47:45</pubDate>
<link>http://www.example.com/bloggers.php?id=366</link>
<description>Synopsis of the article here.</description>
</item>
....more items...
</channel>
</rss>

What I would like to be able to do is display the BlogSite description
as the form title, show the site description in a label control, and
display the copyright info at the bottom of the form.

I am guessing I will be able to cope with reading the items into some
dis[play format once I sort out the title issues.

Any help that anyone can give me would be greatly appreciated.

Thanks In Advance
Marc.
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hello Marc,

You could employ an XSL stylesheet to convert the RSS data to a piece of
HTML. Or, if your app is a Windows app, you can read the RSS XML with the
standard XmlReader, or even load it to an XmlDocument instance.
 
M

Marc Jennings

Dmitriy,

Thanks. I have used the following code to read the XML...

XmlTextReader tr = new XmlTextReader("URL of file");

If I then use
while(tr.Read())
{
listBox1.Items.Add(tr.Name);
}
I can populate a list box with the names of the tags, but I can';t for
the life of me figure out how I can reference the specific elements
within the <content> tags, but outside the <item> ones.
 
D

Dmitriy Lapshin [C# / .NET MVP]

Marc,

The XmlTextReader class should read elements one-by-one, sequentially
traversing the XML document tree, so it should yield all the tags. This is
convenient if you want to process all the contents of an XML document. If
you just want to access particular tags, you could load the RSS to an
XmlXPathDocument and then issue XPath queries against the document to
retrieve the values of the tags in question.
 
A

Anders Eriksson

Hello Marc!


I am trying to write a small windows app to keep track of a couple of
blogs. The blogs I want to look at are available as RSS feeds through
a static URL.

Have a look at RSS.NET; an open-source .NET class library for RSS feeds.
http://www.rssdotnet.com/

Maybe it will help you!

// Anders
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

XPath issue 2
Read XML file into GridView 2
Need an explanation rss xml 4
Simple XML parsing question.. 2
XPath help 1
RSS feed XML linq 2
showing date on ashx page (rss) 4
How to use rss 7

Top