Ver Mensaje Individual
  #1 (permalink)  
Antiguo 12/02/2010, 12:24
Mikelon85
 
Fecha de Ingreso: diciembre-2002
Ubicación: bilbao
Mensajes: 345
Antigüedad: 23 años, 10 meses
Puntos: 3
Problema al crear un XML

Código PHP:
<?php
//header('Content-type: text/xml; charset=UTF-8');
include("con.inc");
$link = Connect();
if (!isset(
$_GET["num"])) {
    echo 
"ERROR, dame un numero!";
    exit;
}
$prints = 50;
$sum = 0;
$sitemapnum = $_GET["num"];
$min = $sitemapnum * $prints;
$sacar = mysql_query("SELECT id,titulo,artist FROM files LIMIT $min,$prints");
$XML="<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
$XML.="<urlset xmlns=\"http://www.google.com/schemas/sitemap/0.84\">\n";
while (
$ver = mysql_fetch_assoc($sacar)) {
    
$sum++;
    
$numrand = rand(2000,4000);
    
$fecha = date("Y-m-d");
    
$id= $ver["id"];
    
$titulo = utf8_decode($ver["titulo"]);
    
$artist = utf8_decode($ver["artist"]);
    
$texto_indexa = $titulo."-".$artist;
    
$texto_indexa = preg_replace('/\s+/', ' ', $texto_indexa);
    
$texto_indexa = str_replace("#", "", $texto_indexa);
    
$texto_indexa = str_replace(" ", "-", $texto_indexa);
    
$texto_indexa = str_replace("%", "", $texto_indexa);
    
$texto_indexa = str_replace("/", "-", $texto_indexa);
    
$texto_indexa = str_replace('"\"', "-", $texto_indexa);
    
$texto_indexa = str_replace("`", "", $texto_indexa);
    
$texto_indexa = str_replace("'", "", $texto_indexa);
    
$texto_indexa = str_replace("ñ", "n", $texto_indexa);
    
$texto_indexa = str_replace("'", "-", $texto_indexa);
    
$texto_indexa = str_replace("´", "-", $texto_indexa);
    
$link_indexa = $id.'/'.$texto_indexa;
    
$url = 'http://www.dominio.com/go/'.$link_indexa;
    
$XML.= "<url>";
    
$XML.= "<loc>".$url."</loc>";
    
$XML.= "<lastmod>{$fecha}T14:18+00:00</lastmod>\n";
    
$XML.= "<changefreq>weekly</changefreq>\n";
    
$XML.= "<priority>0.{$numrand}</priority>\n";
    
$XML.="</url>";
}
$XML.="</urlset>";
echo 
$XML; // devuelve el xml
?>
El problema es que a pesar del utf_encode, el XML me da error:

Error de lectura XML: entidad no definida
Ubicación: http://domain.com/sitemaps/genera.php?num=2
Número de línea 122, columna 96:</url><url><loc>http://www.domain.com/go/134242/el-sue&ntilde;o-de-morfeo</loc><lastmod>2010-02-12T14:18+00:00</lastmod>
-----------------------------------------------------------------------------------------------^

Ya que me convierte las ñ en &ntilde; es decir, no me hace caso con el utf8_encode

__________________
aste nagusia