jueves, 3 de julio de 2014

Leyendo RSS con PHP

<?php
header('Content-Type: text/html; charset=utf-8');
$url = "[URL]";
$rss = simplexml_load_file($url);
if($rss)
{
echo '<h1>'.$rss->channel->title.'</h1>';
echo '<p>'.$rss->channel->pubDate.'</p>';
$items = $rss->channel->item;
foreach($items as $item)
{
$title = $item->title;
$link = $item->link;
$published_on = $item->pubDate;
$description = $item->description;
$totallen = strlen($title);
echo '<h3><a href="'.$link.'">'.$title.'</a></h3>';
echo '<span>('.$published_on.')</span>';
echo '<p>'.$description.'</p>';
}
}
?>

No hay comentarios:

Publicar un comentario