Disculpen sino deje el código. Estaba un poco apurado .... :-p pero bueno aquí esta:
Código PHP:
if ( $opt == "crear" ) {
$pubDate = date("D M j G:i:s T Y");
$contar_noticias = $db->Execute("SELECT COUNT(IDN) AS cantidad FROM noticia");
$rscantidad = $contar_noticias->fetchRow();
# RSS File
$res = "";
$res.= "<?xml version="1.0\" encoding=\"UTF-8\"?>\n";
$res.= "<rss version=\"2.0\">\n";
$res.= "\t<channel>\n";
$res.= "\t\t<title><![CDATA[RSS Portal de los JCCE de Granma]]></title>\n";
$res.= "\t\t<description><![CDATA[RSS Portal de los JCCE de Granma]]></description>\n";
$res.= "\t\t<language>es-es</language>\n";
$res.= "\t\t<generator>RSS Portal JClub Granma</generator>\n";
$res.= "\t\t<link>http://www.jovenclub.cu/grm/tinogrm.rss</link><description>RSS Portal de los JCCE de Granma></description><language>es-ES</language><pubDate>". $pubDate ."</pubDate>\n";
$res.= "<image><title>RSS Portal de los JCCE de Granma</title><url>http://www.jovenclub.cu/grm/tinogrmrss.png</url><link>http://www.jovenclub.cu/grm/tinogrm.rss</link></image>\n";
if ($rscantidad[0] > 0) {
$fecha_noticias= $db->SQLDate('d M Y - h:i:s A', 'FechaN');
$noticia = $db->Execute("SELECT IDN, IDC, $fecha_noticias, TituloN, DescN,ImgN, AutorN FROM noticia WHERE (NACtiva<>0) ORDER BY FechaN DESC");
while ( $rs = $noticia->fetchRow() ) {
$res.="\t\t<item>\n";
$res.="\t\t\t<title><![CDATA[" . htmlspecialchars($rs['TituloN']) . "]]></title>\n";
$res.="\t\t\t<description><![CDATA[ <p><b> ";
if ($rs['ImgN'] !=""){
$res.="<img src=http://www.jovenclub.cu/grm/themes/images/noticias/". $rs['ImgN'] ." align=left >";
}else{
$res.="<![CDATA[" . htmlspecialchars( $rs['DescN']) . "]]></description>\n";
}
$res.="\t\t\t<pubDate>" . $fecha_noticias . "</pubDate>\n";
$res.="\t\t\t<link>" . $PageAdress . "&IDC=" . $rs['IDC'] . "&IDN=" . $rs['IDN'] . "</link>\n";
$res.="\t\t\t<author>" . htmlspecialchars( $rs["AutorN"] ) . "</author>\n";
$res.="\t\t</item>\n";
}
}
$res.= "\t\t</channel>\n";
$res.= "\t\t</rss>\n";
$tpl->assign('file', 'tinogrm.xml');
$actual =date("Ymd");
$handler=fopen("../tinogrm.xml", 'w+');
if (!fputs($handler, $res)) {
$tpl->assign("msg","No se pudo crear el RSS");
} else {
$tpl->assign("msg","El fichero RSS ha sido creado satisfactoriamente");
}
fclose($handler);
$file = "tinogrm.xml";
$tpl->assign('file', $file);
}
Salu2