|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Best way to programmatically add to an RSS Feed?
I have my RSS done, happy with the results. However I build my RSS programatically and I want it to maintain itself via a chron job I have setup.
Using PHP whats the best way to maintain the RSS feed? The problem as I see it is that new articles are at the top of the <item> lists, which PHP wont let me just add in, so I have to read in the entire file, insert my new <item> and then re-write the entire file. This is fine for a few entries, but seems a pain if my feed gets to any length. I was sorta kicking the DOMXML functions around, but looks like the same idea, I have to write the entire XML file to memory, then output it again with any additional nodes I want. So whats my best bet here? Suggestions? Cul |
|
#2
|
|||
|
|||
|
You're pretty much stuck there. Unless you know the exact byte in the file where you want to insert the new data you pretty much have to read it all into memory.
On the plus side, you're worrying over nothing. Assuming you're meaning for people to actually be able to download your RSS file the size is going to be plenty small enough that reading/modifying/writing will be quite snappy. You could also take the approach of dynamically generating the RSS when someone requests it. I'd recommend the other approach, though. Unless you're writing new articles every few minutes it's probably better to have a static file. |
|
#3
|
|||
|
|||
|
Thanks for the reply. I have sorta been thinking of doing both approaches. Put the most recent items as a static file, thus letting me keep it fairly small, and have all entries in my mysql database that I can dynamically generate an RSS for on a users request for people that want older references.
Its a way forward at any rate If I did know the exact byte that I wanted to insert data into the file, how would I go about doing that?Cul |
|
#4
|
|||
|
|||
|
Google around for "fixed length record". It's not too terribly simple. Here are a few references: http://www.cs.sfu.ca/CC/354/zaiane/...r10/node15.html
http://iis1.cps.unizar.es/Oreilly/p...ook/ch08_16.htm |
|
#5
|
|||
|
|||
|
Also look for "random access file". You'll need both techniques, and this one is probably the better place to start, actually.
Here's a description: http://webster.cs.ucr.edu/Page_AoAL...TML/Files3.html Here's some info on using php: http://www.mail-archive.com/php-win...t/msg17555.html It's going to be a challenge to do this with xml data, though. |
|
#6
|
|||
|
|||
|
Ok thanks, I will do some reading!
Cul |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > XML Programming > Best way to programmatically add to an RSS Feed? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|