开发者

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 (b开发者_JS百科oth sides - server and client)


$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.


Well, to answer your first question, I would just write a simple script that parses the feed (check out this and php.net) and stores them in the database.

While doing that, you would store the timestamps. To generate them, you could for example start with the current timestamp, and simply adding 3600 (as php uses unix timestamps and 3600 seconds represent 1 hour) each time you insert a row.

For the last question, take a look at this article.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜