extracting data from rss feed.

Associate
Joined
18 Oct 2002
Posts
679
Location
Nr. Glasgow
Hello,

I have a rss xml file that I would like to extract the data between the link, title and description tags into an array for eventual insertion into a db. Is this something thats possible in php without too much work? I have done some php coding before but nothing too complicated and I dont really know where to start with this.

Thanks.

Dave
 
I am using PHP5. I had looked at various prebuilt scripts but many of them seemed overly complicated for what I need..

Magpie looks very nice, will try it shortly :)

Given that I dont really want to display the data direct from the rss feed I may look at building my own solution from the SimpleXML funcs.

Thanks.
 
Dave77 said:
Given that I dont really want to display the data direct from the rss feed I may look at building my own solution from the SimpleXML funcs.
There's not much involved. Something of the fashion:
Code:
$feed = 'http://foo.com/bar.xml';
$xml_data = simplexml_load_file($feed);

$info = array('description' => $xml_data->channel->description,
              'language'    => $xml_data->channel->language,
              'link'        => $xml_data->channel->link,
              'title'       => $xml_data->channel->title);

$num = 5; // Number of feed items to retrieve
$items = $xml_data->xpath("//item[position()<=$num]");
should work :).
 
Back
Top Bottom