Page 1 of 1

Using PHP to update RSS

Posted: Fri Jul 13, 2007 4:48 am
by ayfine
I am completely new to RSS and I haven't found any places that explain how to update an RSS feed with php.

I have my ideas about how to do it, mainly doing something like

Code: Select all

header('Content-Type: text/xml');
And then using mysql queries to grab information. Is this the right way to go about doing this?

edit

I went ahead and tried this and when I was declaring the xml version, because the tags end in ?> it gave an error.

Posted: Fri Jul 13, 2007 5:11 am
by Rovas
You attach a timestamp to the RSS code using

Code: Select all

date()
  mktime()
Also read the php function that deal with XML
EDIT
Use XPath to search the xml document for the time :

Code: Select all

<lastBuildDate>
and then delete that news item :)

Posted: Fri Jul 13, 2007 5:54 am
by idevlin
Hmmm, I just opened the file, and added the new details to it and closed it again.

Can't use the fancy XML parsing stuff that comes with PHP5 as my host still has PHP4. Ho hum.