====== XML Reader/ RSS Feed ======
I wanted my own ad-free RSS Reader...
===== Code =====
I didnt want to load the .xml on access because I have this feed on the page which opens everytime I open a new tab in my browser.
Add to crontab
*/15 * * * * wget -O -q ''
Add to webserver
") or die("Error: Cannot create object");
$news = $xml->xpath('//item');
//#### Create Table ####
echo '';
//#### Foreach news article do ####
foreach($news as $a)
{
//#### Title of news ####
echo '' . $a->title . ' |
';
//#### Date of news ####
echo '' . $a->pubDate . ' |
';
//#### Picture in news ####
echo ' | ';
//#### Remove HTML tags from description ####
$desc = strip_tags($a->description);
//#### Open function to limit text to 250 chars ####
echo '' . truncate($desc) . ' |
';
//#### Some empty rows ####
echo '
|
';
echo '
|
';
}
echo "
";
//#### Function to limit text to 250 chars ####
//#### https://stackoverflow.com/questions/3161816/get-first-n-characters-of-a-string ####
function truncate($string,$length=250,$append="…") {
$string = trim($string);
if(strlen($string) > $length) {
$string = wordwrap($string, $length);
$string = explode("\n", $string, 2);
$string = $string[0] . $append;
}
return $string;
}
?>
Insert to your page for the feed
\\
\\
~~DISCUSSION:closed~~