tags:

views:

171

answers:

1

what is the best way to detect whether a given url is actually an RSS feed?

+3  A: 

It's tough to do reliably if the URLs you need to check are arbitrary.

One thing would be the content-type it serves. That can change, though, because (IIRC) IE needs text/xml to display an actual feed, and not to offer to download it. For more on the issue see here.

The second (and more reliable) thing would be to analyze the file's structure. Some ideas are here: How to detect if a page is an RSS or ATOM feed

The simplest way could be, as Pascal Martin recommends in that question, opening an URL with the Zend RSS reader. If that works out, it's a valid RSS resource, otherwise, it's not.

Pekka