Ejemplo de como consumir el RSS desde XML utilizando PHP como lenguaje de programación

Hola, buenas, les traigo un ejemplo sombre el consumo de datos desde un archivo xml tomando de un RSS (Really Simple Syndication) de este blog en el cual utilizo php para obtener el archivo xml e iterarlo para imprimir el contenido.

Espero les sea útil en algún proyecto que tengas. Saludos :]

<?php
// $urlRSS = 'http://nelsonkewebs.tumblr.com/rss';
$urlRSS = 'http://feeds.feedburner.com/nelsonkewebs';
$XML = simplexml_load_file($urlRSS);

$items = $XML->channel->item;
?>
<!DOCTYPE html>
<html>
 <head>
  <meta charset="UTF-8" />
  <title>XML Load RSS Publish</title>
  <style>
   body 
   {
    background: #333;
    font-size: 16px;
    font-family: Arial, sans-serif;
   }
   
   h1
   {
    color: white;
    font-family: Pacifico, Arial, serif;
    font-size: 4em;
    text-align: center;
    text-shadow: cyan 0px 0px 5px;
   }
   section 
   {
    max-width: 980px;
    margin: 0 auto;
   }

   article
   {
    background: white;
    border-radius: .3em;
    margin-bottom: 2em;
    padding: 1em;
   }

   article a 
   {
    text-decoration: none;
    color: orange;
   }

   article a:hover
   {
    text-decoration: underline;
   }
   
   .Item-date
   {
    font-size: 0.8em;
    font-style: italic;
    color: gray;
    margin-bottom: 1em;
   }
  </style>
 </head>
 <body>
  <head>
   <h1>Nelsonkewebs by RSS XML PHP</h1>
  </head>
  <section>
  <?php foreach ($items as $item): ?>
   <article>
    <h2 class="Item-title"><a href="<?php echo $item->link; ?>" target="_blank"><?php echo $item->title; ?></a></h2>
    <div class="Item-date"><?php echo $item->pubDate; ?></div>
    <div class="Item-content"><?php echo $item->description; ?></div>
   </article>
  <?php endforeach; ?>
  </section>
 </body>
</html>

Comentarios

Entradas populares de este blog

Instalación de Zorin OS Lite 15.2 x86 (32 bits) para equipos con hardware de bajos recursos

Guía de inicio básica para nginx en Windows 10

Una forma de como solucionar el error 1402 en Office 2007 a 2013 en Windows 7 y Windows 8