Search code examples
phprsssimulationfeed

How to create php RSS simulator?


So I have RSS feed of 10 000 records in file.xml (I collected them from 10 feeds in 1 hour time so there timestamps will not help, btw I used yahoo pipes). I need some class to simulate that records appearing 24 per a day with 1 per hour.

How I see it:

  1. turn file.xml into sql table (if you know a class for this please help)

  2. create timestamps (can any one give a good way for generating timestamps for 10 000 records?)

  3. create class for returning rss (looking at computer clock and returning records from first to now) (could you please provide a way for generating valid RSS from DB?)

So please provide any help if you can.

I use xampp as php apache mysql server holder.

I am going to use it localy in my dev machin (both sides - server and client)


Solution

  • $doc = new DOMDocument();
    $doc->loadHTMLFile($file);
    
    $xpath = new DOMXpath($doc);
    $elements = $xpath->query("//fileroot/nodes");
    if (!is_null($elements)) {
      $dateinterval = [0 hours];
    
      foreach ($elements as $element) {
         // read each node and then store it...
         $storycontents = $element->nodeValue;
         $storytimestamp = date() - $dateinterval;
         $dateinterval = $dateinterval - [1 hour];
    
         [add story to rss feed]
      }
    }
    
    [render all of the collected rss feed stories]
    

    Some of it is pseudocode where you can fill it out. But something along these lines basically.