Home > Archive > PHP Programming > December 2005 > How old is this RSS file?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
How old is this RSS file?
|
|
|
| Hi,
I am trying to parse some RSS files on my site to give a bit of news.
But some of the RSS are sometimes very old, (or just not updated anymore).
Is there a way of getting the age, (last updated), of a remote file?
I guess could always store the whole xml in the db and compare it every day
to see when last it was updated.
But I was hopping there might be an easier way.
how can I tell how old the rss file really is?
Simon
| |
| ZeldorBlat 2005-12-15, 6:57 pm |
| You can look at the <dc:date> element inside the <channel> element.
Not sure if this is required or not (it might not be), but it should
tell you when the feed was last updated (according to the author,
anyway).
But whether you fetch the whole thing and compare it to the previous
day or fetch the whole thing and compare the date to your stored "last
updated" field, you still need to fetch the feed. And, if you needed
to compare the whole file, so what? You're only doing it once per day.
| |
| Philip Ronan 2005-12-15, 6:57 pm |
| "Simon" wrote:
> Hi,
>
> I am trying to parse some RSS files on my site to give a bit of news.
> But some of the RSS are sometimes very old, (or just not updated anymore).
>
> Is there a way of getting the age, (last updated), of a remote file?
> I guess could always store the whole xml in the db and compare it every day
> to see when last it was updated.
> But I was hopping there might be an easier way.
>
> how can I tell how old the rss file really is?
I assume you're using the Curl library to fetch the RSS file. Try setting
CURLOPT_HEADER in a curl_setopt() command, and look for a Last-Modified
header in the returned content. Obviously there's no guarantee that this
header will actually be present.
The best solution would be to keep a local cache of the RSS feed and note
the date when any changes are made to it.
--
phil [dot] ronan @ virgin [dot] net
http://vzone.virgin.net/phil.ronan/
|
|
|
|
|