Mucho tiempo estuve buscando como tambien creo que mucho de ustedes la forma de crear un xml para hacer un RSS desde una DB o una página PHP.
Bueno les paso el código enterito, simplemente le cambian los datos de su db y listo.
Código PHP:
<?
// prepare HTML text for use as UTF-8 character data in XML
function cleanText($intext) {
return utf8_encode(
htmlspecialchars(
stripslashes($intext)));
}
// set the file's content type and character set
// this must be called before any output
header("Content-Type: text/xml;charset=utf-8");
// retrieve database records
include('Connections');
// the file db_connect.php contains only one line:
$db = mysql_pconnect("localhost", "user", "pass");
// it should be readable only by the user running the Web server
// and saved outside of the directory tree that holds Web pages
if (!$db)
{
error_log("Error: No se puede conectar con la base de datos desde esta página.");
exit;
}
//store items from the database in the $result1 array
mysql_select_db("db");
$query1 = "SELECT idnota, titulo, copete FROM noticias ORDER BY idnota DESC limit 10";
$result1 = mysql_query($query1);
$phpversion = phpversion();
// display RSS 2.0 channel information
$charset = "iso-8859-1";
echo '<?xml version="1.0" encoding="' . $charset . '"?'.'>';
echo <<<end
<rss version="2.0">
<channel>
<title>Titulo del sitio</title>
<link>http://www.sitio.com.ar</link>
<description>Portal de noticias nacionales e internacionales </description>
<language>es_ES</language>
<docs>http://www.sitio.com.ar/notocias/rss.php</docs>
<generator>PHP/$phpversion</generator>
end;
// loop through the array pulling database fields for each item
for ($i = 0; $i < mysql_num_rows($result1); $i++) {
@$row = mysql_fetch_array($result1);
$titulo = cleanText($row["titulo"]);
$link = "http://www.sitio.com.ar/noticias/noticia.php?idnota=".
cleanText($row["idnota"]);
$descripcion = cleanText($row["descripcion"]);
// display an item
echo <<< end
<item>
<title>$titulo</title>
<link>$link</link>
<description>$descripcion</description>
</item>
end;
}
echo <<< end
</channel>
</rss>
end;
?>


Gracias JP!!!!
Saludos a todos
