Te expongo una forma sencilla de crear RSS
Código PHP:
Ver original<?php
class rss2 extends DOMDocument {
private $channel;
public function __construct($title, $link, $description) {
parent::__construct();
$this->formatOutput = true;
$root = $this->appendChild($this->createElement('rss'));
$root->setAttribute('version', '2.0');
$channel= $root->appendChild($this->createElement('channel'));
$channel->appendChild($this->createElement('title', $title));
$channel->appendChild($this->createElement('link', $link));
$channel->appendChild($this->createElement('description', $description));
$this->channel = $channel;
}
public function addItem($title, $link, $description) {
$item = $this->createElement('item');
$item->appendChild($this->createElement('title', $title));
$item->appendChild($this->createElement('link', $link));
$item->appendChild($this->createElement('description', $description));
$this->channel->appendChild($item);
}
}
$rss = new rss2('Foros del web', 'http://www.forosdelweb.com/f18/','Foro de PHP');
$rss->addItem('foo', 'http://www.example.org/foo','foo Descripción');
$rss->addItem('bar', 'http://www.example.org/bar','bar Descripción');
echo $rss->saveXML();
Esto escribirá
Código XML:
Ver original<?xml version="1.0"?>
<rss version="2.0">
<channel>
<title>Foros del web</title>
<link>http://www.forosdelweb.com/f18/</link>
<description>Foro de PHP</description>
<item>
<title>foo</title>
<link>http://www.example.org/foo</link>
<description>foo Descripci</description>
</item>
<item>
<title>bar</title>
<link>http://www.example.org/bar</link>
<description>bar Descripci</description>
</item>
</channel>
</rss>