473,396 Members | 1,738 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,396 software developers and data experts.

Consuming RSS Feeds Exceptions

I built an asp.net usercontrol that consumes rss feeds that I specify
the url for.

Some of them (MVP blogs, google news) consumes the feeds just fine. and
other times (75%) it chokes on stream.length and stream.position with
an Exception of type System.NotSupportException.

It seems as if with some RSS feeds, they are not formatted correctly?
What can I do to get these to work properly.

One that is giving me problems is the slashdot rss :
http://rss.slashdot.org/Slashdot/slashdot

I will put error reporting in there so if the feed is bad, it won't
consume it, but i'm just trying to figure out why it would choke on
these feeds. The RSS xml looks ok, so I dont really understand what the
problem is.

Any help would be greatly appreciate. here is a snippet of code i'm
using to consume the feed:

WebRequest request;

WebResponse response;

Stream stream;

XmlTextReader reader;

XmlDocument xmldoc;

request = WebRequest.Create(url);

response = request.GetResponse();

stream = response.GetResponseStream(); <--CHOKES HERE

// Create new XmlTextReader and XmlDoc

reader = new XmlTextReader(stream); <-- AND SOMETIMES HERE

xmldoc = new XmlDocument();

xmldoc.Load(reader);

Xml pageXML = new Xml();

pageXML.Document = xmldoc;

pageXML.TransformSource = "~/style/RSSReader.xsl";

// Add to plFeeds placeholder

this.plFeeds.Controls.Add(pageXML);

reader.Close();

stream.Close();

request = null;

response = null;

stream = null;

reader = null;

xmldoc = null;

May 24 '06 #1
2 1520
dkode wrote:
I built an asp.net usercontrol that consumes rss feeds that I specify
the url for.

Some of them (MVP blogs, google news) consumes the feeds just fine. and
other times (75%) it chokes on stream.length and stream.position with
an Exception of type System.NotSupportException.
It looks like the stream that is returned is a ConnectStream which
doesn't support the Length and Position properties. (This has got to
violate some principle of OO design...)

The XmlTextReader might be seeing invalid xml and trying to recover by
looking ahead or behind. You could try copying the stream to a
MemoryStream or saving to a file for debugging purposes and then loading
it. XmlTextReader might give some a more useful error message that way.
It seems as if with some RSS feeds, they are not formatted correctly?
What can I do to get these to work properly.
There are a lot of feeds that are not valid out there. I refreshed the
Slashdot feed in Firefox a few times and it was usually valid, but not
always. 9 out of 10 it was valid though.
One that is giving me problems is the slashdot rss :
http://rss.slashdot.org/Slashdot/slashdot


The Slashdot rss only works sometimes for me, so something is at the
very least odd with the feed.
Some quick and dirty code to copy the stream into a new MemoryStream:

MemoryStream memoryStream = new MemoryStream();
StreamReader streamReader = new StreamReader(stream);
StreamWriter streamWriter = new StreamWriter(memoryStream);
while(!streamReader.EndOfStream)
{
string line = streamReader.ReadLine();
streamWriter.WriteLine(line);
}
memoryStream.Position = 0;
--
David Hogue
May 24 '06 #2
Where can I find more information on RSS 2.0, 1.0 and RDF and the
differences between these and how they correlate.

I see that the slashdot rss has an opening tag of <rdf:RDF, while other
feeds have an opening tag of <rss version="2.0"

Do I have to apply a different xsl to format rdf feeds?

This is my first time working with RSS feeds in dotnet and I think I
need to read some information on the actual specification and
differences in these feeds.

Upon further investigation I can take the RSS feed from this newsgroup
via google groups and display it without a problem. At the worst case
scenario, I will just tell the user the feed is not valid. Is there any
exception I can catch to watch for an invalid feed, so that way I dont
have to output non-formattable rss?

thanks for the info!

May 24 '06 #3

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

Similar topics

6
by: plazma_41 | last post by:
Are there any uses for rss feeds on commercial websites selling products/services? Yes! I've just realized that eMaximarket Auctions ( http://www.emaximarket.com ) provides RSS feeds. For...
1
by: richards1052 | last post by:
I am setting up a forum website at which I plan to set up a news aggregator to pick up news headlines about the Mideast. But I've only been able to find a few news resources that have specific...
0
by: jmwatte | last post by:
OK... 2 RSS feeds ... "http://feeds.feedburner.com/brainyquote/QUOTENA" "http://feeds.feedburner.com/qotd" Now I build a RSS reader in C#Express(did several of them including the starterkit)...
2
by: DAL | last post by:
Question: How easy is it to have RSS feeds consumed on my site, and is there any EASY (your dealing with a newbie) tutorials that explain how to write the code. I am looking for a tutorial that...
0
by: JP2006 | last post by:
I'm having an issue with a control I'm writing to consume RSS feeds. It gets a feed via a querystring parameter and sticks it in a dataset. I then use the dataset to write out the feed title and...
2
by: David G | last post by:
My company has a Webservice that is currently running in production. It is secured using SSL and clients are authenticated using X509 certificates. I am able to consume the Webservice methods in...
5
by: Shawn | last post by:
Hi, I want to understand and follow RSS feed because many web pages provide RSS feed for updated new data(e.g. http://www.weather.gov/rss/). But I never get how to use it. The link below suppose...
1
by: Rama Jayapal | last post by:
hi i am developing a web application where i have to read multiple XML feeds amd store their values to database but i require the same type of fields from multiple XML feeds like for...
1
by: Bo | last post by:
Hope somebody can help me. I show some remote rss feeds on my page with this code. But if the remote server is down how do prevent my page from getting an error? In short how do I add some code...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.