user3102785
user3102785

Reputation: 75

Display RSS feed from remote server on my site?

I am attempting to retrieve an RSS feed from a website, and display this content on my site. However, I am getting a Same Origin policy error.

Most of the answers I've seen on here direct users to change their server settings, which obviously isn't possible.

Anyway, how can I retrieve the following RSS feed for example, and then parse it?

http://www.rte.ie/rss/soccer.xml

Upvotes: 1

Views: 79

Answers (1)

Rhega
Rhega

Reputation: 104

You can use RSS Mining and parsing it with PHP

<?php
$rss = array();
$url_src = "http://www.rte.ie/rss/soccer.xml";
$xml = simplexml_load_file($url_src);
foreach ($xml->channel->item as $item) {    
    $_Title= strip_tags($item->title);
    $_Link= strip_tags($item->link);
    $_Date = strip_tags($item->pubDate);
    $_Desc = strip_tags($item->description);

    $rssitem = array($_Title,$_Link,$_Date,$_Desc);
    array_push($rss,$rssitem);
}

// Output
array_map(function ($item) {
    printf("Title: %s<br>Link: %s<br>Date: %s<br>Description: %s<hr>",$item[0],$item[1],$item[2],$item[3]); 
}, $rss);
?>

Upvotes: 1

Related Questions