Tema: RSS en php
Ver Mensaje Individual
  #2 (permalink)  
Antiguo 23/11/2007, 03:23
Avatar de rasmarko
rasmarko
 
Fecha de Ingreso: noviembre-2002
Ubicación: México
Mensajes: 78
Antigüedad: 22 años, 3 meses
Puntos: 1
Re: RSS en php

Para que un archivo .xml interprete codigo PHP necesitas poner, si usasApache, en tu htaccess:

AddType application/x-httpd-php .xml

Luego guarda tu archivo con extensión .xml y similar al siguiente contenido:

Cita:
<?
header("Content-Type: text/xml; charset=UTF-8");
echo '<?xml version="1.0" encoding="ISO-8859-1" ?>';
?>
<rss version="2.0">

<channel>
<title>RSS Guia Facil</title>
<link>http://es.geocities.com/rss_guia_facil</link>
<description>Guia fácil y sencilla sobre el formato RSS</description>

<?

$sql = "SELECT * FROM ...";
$resource = mysql_query($sql);

while($campos = mysql_fetch_array($resource)) {
?>
<item>
<title><?=$campos['titulo']?></title>
<link><?=$campos['link']?></link>
<description><?=$campos['descripcion']?></description>
</item>
<? } ?>

</channel>
</rss>
Te recomiendo que verifiques tambien el estandar del RSS 2.0, hay etiquetas obligatorias que no haz puesto, guiate con esta Genial página de validación Feed:
http://www.feedvalidator.org

Mucha suerte!
__________________
Fuentes - Diseweb - Frases Célebres