I would like to fetch a news website using its RSS feed and PHP language, the function getFeed()
normally will do that for me using file_get_contents($url)
as follow:
<?php
function getFeed() {
$content = file_get_contents('http://echoroukonline.com/ara/feed/index.rss');
$content = simplexml_load_string($content);
print_r($data);
}
?>
I call this function on my page html on a <div>
element, my html page look like:
<?php
include('core/init.inc.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Bienvenu</title>
<meta http-equiv="Content-type" content="text/html; charset=UTF-8"/>
</head>
<body>
<div>
<?php
getFeed();
?>
</div>
</body>
</html>
I include on this webpage an initialization function:
<?php
$path=dirname(__FILE__);
include("{$path}/inc/rssnews.inc.php");
?>
But when I run this page on the navigator I don't get the display of the RSS feed of the website, I just get the html page as it is shown. So, how could I solve this problem and read the RSS feed of my website?