Ver Mensaje Individual
  #4 (permalink)  
Antiguo 22/05/2010, 09:11
Avatar de abimaelrc
abimaelrc
Colaborador
 
Fecha de Ingreso: mayo-2009
Ubicación: En el planeta de Puerto Rico
Mensajes: 14.734
Antigüedad: 14 años, 11 meses
Puntos: 1517
Respuesta: por qué mi rss no muestra las noticias??

Te expongo una forma sencilla de crear RSS
Código PHP:
Ver original
  1. <?php
  2. class rss2 extends DOMDocument {
  3.     private $channel;
  4.     public function __construct($title, $link, $description) {
  5.         parent::__construct();
  6.         $this->formatOutput = true;
  7.         $root = $this->appendChild($this->createElement('rss'));
  8.         $root->setAttribute('version', '2.0');
  9.         $channel= $root->appendChild($this->createElement('channel'));
  10.         $channel->appendChild($this->createElement('title', $title));
  11.         $channel->appendChild($this->createElement('link', $link));
  12.         $channel->appendChild($this->createElement('description', $description));
  13.         $this->channel = $channel;
  14.     }
  15.  
  16.     public function addItem($title, $link, $description) {
  17.         $item = $this->createElement('item');
  18.         $item->appendChild($this->createElement('title', $title));
  19.         $item->appendChild($this->createElement('link', $link));
  20.         $item->appendChild($this->createElement('description', $description));
  21.         $this->channel->appendChild($item);
  22.     }
  23. }
  24.  
  25. $rss = new rss2('Foros del web', 'http://www.forosdelweb.com/f18/','Foro de PHP');
  26. $rss->addItem('foo', 'http://www.example.org/foo','foo Descripción');
  27. $rss->addItem('bar', 'http://www.example.org/bar','bar Descripción');
  28. echo $rss->saveXML();
Esto escribirá
Código XML:
Ver original
  1. <?xml version="1.0"?>
  2. <rss version="2.0">
  3.   <channel>
  4.     <title>Foros del web</title>
  5.     <link>http://www.forosdelweb.com/f18/</link>
  6.     <description>Foro de PHP</description>
  7.     <item>
  8.       <title>foo</title>
  9.       <link>http://www.example.org/foo</link>
  10.       <description>foo Descripci</description>
  11.     </item>
  12.     <item>
  13.       <title>bar</title>
  14.       <link>http://www.example.org/bar</link>
  15.       <description>bar Descripci</description>
  16.     </item>
  17.   </channel>
  18. </rss>
__________________
Verifica antes de preguntar.
Los verdaderos amigos se hieren con la verdad, para no perderlos con la mentira. - Eugenio Maria de Hostos