473,378 Members | 1,378 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Parsing RSS (XML)

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.
Nov 16 '05 #1
4 5908
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.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Marc Jennings" <marc.nospam..je******@gmail.com> wrote in message
news:46********************************@4ax.com...
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.


Nov 16 '05 #2
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.

On Thu, 22 Jul 2004 11:58:48 +0300, "Dmitriy Lapshin [C# / .NET MVP]"
<x-****@no-spam-please.hotpop.com> wrote:
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.


Nov 16 '05 #3
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.

--
Sincerely,
Dmitriy Lapshin [C# / .NET MVP]
Bring the power of unit testing to the VS .NET IDE today!
http://www.x-unity.net/teststudio.aspx

"Marc Jennings" <marc.nospam..je******@gmail.com> wrote in message
news:el********************************@4ax.com...
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.

On Thu, 22 Jul 2004 11:58:48 +0300, "Dmitriy Lapshin [C# / .NET MVP]"
<x-****@no-spam-please.hotpop.com> wrote:
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.


Nov 16 '05 #4
Hello Marc!
On Thu, 22 Jul 2004 09:35:54 +0100, Marc Jennings wrote:
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
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Willem Ligtenberg | last post by:
I decided to use SAX to parse my xml file. But the parser crashes on: File "/usr/lib/python2.3/site-packages/_xmlplus/sax/handler.py", line 38, in fatalError raise exception...
2
by: Cigdem | last post by:
Hello, I am trying to parse the XML files that the user selects(XML files are on anoher OS400 system called "wkdis3"). But i am permenantly getting that error: Directory0: \\wkdis3\ROOT\home...
3
by: Girish | last post by:
Hi All, I have written a component(ATL COM) that wraps Xerces C++ parser. I am firing necessary events for each of the notifications that I have handled for the Content and Error handler. The...
4
by: ralphNOSPAM | last post by:
Is there a function or otherwise some way to pull out the target text within an XML tag? For example, in the XML tag below, I want to pull out 'CALIFORNIA'. ...
3
by: Pir8 | last post by:
I have a complex xml file, which contains stories within a magazine. The structure of the xml file is as follows: <?xml version="1.0" encoding="ISO-8859-1" ?> <magazine> <story>...
3
by: David Svoboda | last post by:
I have a server program that takes commands and acts on them. The server program can also take these commands from an input file or standard input (mainly for testing purposes). As such, I often...
5
by: randy | last post by:
Can some point me to a good example of parsing XML using C# 2.0? Thanks
3
by: Anup Daware | last post by:
Hi Group, I am facing a strange problem here: I am trying to read xml response from a servlet using XmlTextWriter. I am able to read the read half of the xml and suddenly an exception:...
2
by: nicky123 | last post by:
Hi everyone, This is a brief description that I have provided for parsing & displaying an XML document using DOM API. Please feel free to post your own comments & views regarding...
5
by: PatlaDJ | last post by:
Java SAX parser, please need a clue how to get the raw XML code of the currently parsing event... needed for logging, debugging purposes. Here's and example, letting me clarify exactly what i...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.