Ver Mensaje Individual
  #3 (permalink)  
Antiguo 19/09/2008, 04:18
b_all_ell
 
Fecha de Ingreso: mayo-2008
Mensajes: 14
Antigüedad: 16 años
Puntos: 0
Respuesta: leer un archivo xml con php y meter los datos en una mysql

siguiendo este enlace,
tengo esto:

function CargarXML($ruta_fichero)
{
$contenido = "";
if($da = fopen($ruta_fichero,"r"))
{
while ($aux= fgets($da,1024))
{
$contenido.=$aux;
}
fclose($da);
}
else
{
echo "Error: no se ha podido leer el archivo <strong>$ruta_fichero</strong>";
}



$tagnames = array ("titulo","autor","cuerpo");

if (!$xml = domxml_open_mem($contenido))
{
echo "Ha ocurrido un error al procesar el documento<strong> \"$ruta_fichero\"</strong> a XML <br>";
exit;
}
else
{
$raiz = $xml->document_element();

$tam=sizeof($tagnames);

for($i=0; $i<$tam; $i++)
{
$nodo = $raiz->get_elements_by_tagname($tagnames[$i]);
$j=0;
foreach ($nodo as $etiqueta)
{
$matriz[$j][$tagnames[$i]]=$etiqueta->get_content();
$j++;
}
}

return $matriz;
}
}

en esta parte
$tagnames = array ("titulo","autor","cuerpo");

que tendria que poner??