Reputation: 487
Is there a way to put multiple xml feed into one xml feed and order it by date of publish?
The xml feed is from different websites and I want to create another xml to put all the contents of each xml feed.
The problem is the loading time to parse all the xml feeds. I got 8 website feeds to parse. Another problem is how do I arrange them by publishing date.
Any help will be appreciated.
Upvotes: 0
Views: 363
Reputation: 2564
You need to create a temporary array and get all the feeds in it. Then sort the array by date and display. To get the items from one feed you can use magpierss to loop through all the items.
Below is an example of how to use magpie rss. Reference: http://magpierss.sourceforge.net/
require_once 'rss_fetch.inc';
$url = 'http://magpie.sf.net/samples/imc.1-0.rdf';
$rss = fetch_rss($url);
$tempArray = array();
foreach ($rss->items as $item ) {
$tempArray[]['title'] = $item['title'];
$tempArray[]['url'] = $item['link'];
$tempArray[]['date'] = $item['pubDate'];
}
In the above example $tempArray will have all items of one feed. Similarly you need to get other items of other feeds into it. And then use uasort to sort by date.
Upvotes: 2