Loading ...
Sorry, an error occurred while loading the content.

Re: Best class/method for reading RSS into PHP?

Expand Messages
  • Ryan David Pardey
    Thanks for the responses regarding this. I ended up using MagpieRSS: This is the code. I stripped out some of the more task specific testing, but this is the
    Message 1 of 3 , Jul 3, 2012
    • 0 Attachment
      Thanks for the responses regarding this. I ended up using MagpieRSS:
      This is the code. I stripped out some of the more task specific testing,
      but this is the basic skeleton. Works fine...
      <?php define('MAGPIE_DIR', './magpierss/');
      require_once(MAGPIE_DIR.'rss_fetch.inc'); $url = "http://your.url.com/";
      $yourXML = fopen("yourxml.xml", 'w'); fwrite($yourXML, "<?xml
      version=\"1.0\" encoding=\"utf-8\"?>\n"); fwrite($yourXML,
      "\t<channel>\n"); $linksCount = 0; if($url){ $rss = fetch_rss($url);
      foreach($rss->items as $item){ if($linksCount > ($numItems-1)){
      break; } $item = array($item['title'],$item['date'],$item['link']);
      $items[$linksCount] = $item; $linksCount++; } } for($i=$linksCount;
      $i>0; $i--){ $thisItem = $items[$i-1]; fwrite($latestNewsXML,
      "\t\t<item>\n"); fwrite($latestNewsXML, "\t\t\t<title>" . $thisItem[0]
      . "</title>\n"); fwrite($latestNewsXML, "\t\t\t<date>" . $thisItem[2] .
      "</date>\n"); fwrite($latestNewsXML, "\t\t\t<link>" . $thisItem[1] .
      "</link>\n"); fwrite($latestNewsXML, "\t\t</item>\n"); }
      fwrite($latestNewsXML, "\t</channel>\n"); fclose($latestNewsXML);?>
      Ryan


      --- In php-objects@yahoogroups.com, JoEi <joei007@...> wrote:
      >
      > Try SimpleXMLElement->xpath, it is very easy to search in XML
      document.
      >
      >
      > On Thu, Jun 28, 2012 at 3:00 AM, Ryan David Pardey
      ryandpardey@...wrote:
      >
      > > **
      > >
      > >
      > > I have a URL for an RSS feed that I need to:
      > >
      > > 1. Read into PHP
      > > 2. Search the <title> tags for key words
      > > 3. Display the document links for key word matches
      > >
      > > Pretty basic, I just haven't done it before. Several code examples
      I've
      > > tried online that use DOMDocument and SimpleXMLElement don't seem to
      work
      > > very well.
      > >
      > > Any suggestions welcome!
      > >
      > > Thanks
      > >
      > >
      > >
      >
      >
      > [Non-text portions of this message have been removed]
      >



      [Non-text portions of this message have been removed]
    Your message has been successfully submitted and would be delivered to recipients shortly.