SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Dec 2005
    Posts
    381
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How to merge RSS feeds to display in one list on php page?

    Hello

    I'm trying to set up a script to combine more than one rss feed and display the posts in date order on a web page.
    I can get this working with one rss file using the script below. Can someone please tell me how I can adapt this code so that it will work using an array of rss files please?

    Thanks for any help in advance with this.

    PHP Code:
    <?php
        $rss 
    = new DOMDocument();
        
    $rss->load('http://news.sky.com/feeds/rss/business.xml');
        
    $feed = array();
        foreach (
    $rss->getElementsByTagName('item') as $node) {
        
    $item = array (
        
    'title' => $node->getElementsByTagName('title')->item(0)->nodeValue,
        
    'desc' => $node->getElementsByTagName('description')->item(0)->nodeValue,
        
    'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
        
    'date' => $node->getElementsByTagName('pubDate')->item(0)->nodeValue,
        );
        
    array_push($feed$item);
        }
        
    $limit 10;
        for(
    $x=0;$x<$limit;$x++) {
        
    $title str_replace(' & '' &amp; '$feed[$x]['title']);
        
    $link $feed[$x]['link'];
        
    $description $feed[$x]['desc'];
        
    $date date('l F d, Y'strtotime($feed[$x]['date']));
        
    $day date('d'strtotime($feed[$x]['date']));
        
    $month date('M'strtotime($feed[$x]['date']));
       
        echo 
    '<div class="entry clearfix">';
        echo 
    '<div class="entry_c">';
        echo 
    '<div class="entry_date">';
        echo 
    '<div class="day">'.$day.'</div>';
        echo 
    '<div class="month">'.$month.'</div>';
        echo 
    '</div>';
        echo 
    '<div class="entry_title"><h2><a href="'.$link.'">'.$title.'</a></h2></div>';
        echo 
    '<div class="clear"></div>';
        echo 
    '<span class="page-divider"><span></span></span>';
        echo 
    '<div class="entry_content">';
        echo 
    '<p>'.$description.'</p>';
        echo 
    '</div>';
        echo 
    '</div>';
        echo 
    '</div>';
        } 
    ?>

  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Do these rss feeds feeds conform to the same standard are all they all different? (atom, rss1, rss2 etc)


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •