SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SEO Link Building Master I, Brian's Avatar
    Join Date
    Apr 2003
    Posts
    1,284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Displaying multiple RSS feeds via PHP?

    I'm trying to create a page that explodes a number of RSS feeds from news sites, so that I creaet a page of headlines from different targeted publications.

    However, I'm not sure how to apply the necessary code.

    At the moment, I call each feed in it's own unique cell using the following code:

    Code:
       <?php
       $xmlfile = fopen("XML/RSSfeedURL", "r");
       if(!$xmlfile)die("cannot open the xml file");
       $readfile = fread($xmlfile ,40000);
       $searchfile = eregi("<item>(.*)</item>", $readfile ,$arrayreg);
       $filechunks = explode("<item>", $arrayreg[0]);
       $count = count($filechunks);
       echo "<table class='featuretable2'>";
       for($i=1 ; $i<=$count-1 ;$i++)
       {
       ereg("<title>(.*)</title>",$filechunks[$i], $title);
       ereg("<link>(.*)</link>",$filechunks[$i], $links);
       echo "<tr><td>";
       echo "<a href ='$links[1]'\>$title[1]</a>";
       echo "</td></tr>";
       }
       echo "</table>";
       ?>
    However, that results in the feeds not being called up or displayed correctly, as you can see here:

    http://www.platinax.co.uk/news/extra/

    Some feeds only display a couple of items, some simply display a prior RSS fragment, rather than their own.

    For example, the SitePoint feed does not work in that environment at all, and only Threawatch actually displays its full feed headlines.

    It was suggested I change the variable names in the above script, but when I changed them all, I simply lost the feeds from all the ones I edited.

    I know it may sound like a very dumb quest - apologies, I have no real programming background - but I'm simply looking to publish multiple feeds on the site, but am having problems doing so.

    I would be very grateful for any help or advice whatsoever on the matter.
    Internet Business Forums - free business help & advice

  2. #2
    SitePoint Guru hgilbert's Avatar
    Join Date
    Dec 2004
    Location
    London
    Posts
    839
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not sure if my advice will help.
    But RSS being XML
    all you need is an XSLT
    I've played with that to get RSS-feeds from BBC say.

    If you want I will fish out for the XSLT and print it here.

    XML x XSLT = XHTML

    I am not a PHP programmer but I am aware it does manipulate XSLT.
    I can fish out the basic PHP code for you too (again if you want to go the XSLT route)


  3. #3
    SEO Link Building Master I, Brian's Avatar
    Join Date
    Apr 2003
    Posts
    1,284
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That would be great if you could - this is new territory for myself as well, but there seems to be an issue in calling up multiple feeds on the same page - I need to find a solution that would allow this without the feeds interfering. It's not even for a commercial project, but it's important to me to get it done.
    Internet Business Forums - free business help & advice

  4. #4
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Have you checked out Kevin Yank's article on RSS and PHP http://www.sitepoint.com/article/php...arsing-rss-1-0

    This might be what you are after

  5. #5
    SitePoint Guru hgilbert's Avatar
    Join Date
    Dec 2004
    Location
    London
    Posts
    839
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    sorry code is broken
    when i make it work i will upload it for you
    i dont know what changed in 3 years time - but something has
    as the code stopped working
    Last edited by hgilbert; Dec 15, 2004 at 11:45. Reason: code is broken


  6. #6
    SitePoint Wizard Mike Borozdin's Avatar
    Join Date
    Oct 2002
    Location
    Edinburgh, UK
    Posts
    1,743
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can try to use PHP native XML functions - SAX parser that is very easy in use
    http://www.php.net/manual/en/ref.xml.php

  7. #7
    SitePoint Guru hgilbert's Avatar
    Join Date
    Dec 2004
    Location
    London
    Posts
    839
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I think it was SP2 that broke my code
    I had a primitive code I wrote some 2/3 years back
    that generated a nice ticker but it did involved grabbing XML as an URL -
    say loading http://news.bbc.co.uk/rss/newsonline...age/rss091.xml

    I never touched the code since but it doesn't work anymore.
    So my guess is that SP2 prohibits that now.

    Anyway two ways to doing a ticker is either using the custom solution suggested
    or writing a cool XSLT.

    really wanted to show my old newsticker it was so damn cute

    lol



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
  •