简体   繁体   中英

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

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);
?>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM