Tema: php + xml
Ver Mensaje Individual
  #6 (permalink)  
Antiguo 14/02/2005, 08:34
Avatar de xknown
xknown
 
Fecha de Ingreso: diciembre-2004
Ubicación: Cusco - Perú
Mensajes: 2.248
Antigüedad: 19 años, 4 meses
Puntos: 7
Hola, el código que enviaste no tiene porque hacer nada, puesto que no recorres el documento XML y es obvio que no se van a ejecutar "apertura" ni "cierre".
El código sería más o menos así:
Código PHP:
<?php echo '<?xml version="1.0" encoding="iso-8859-1"?>'."\n";?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Documento sin t&iacute;tulo</title>
</head>
<body>
<?php
    $documento 
file("data.xml");
    
$manejador xml_parser_create();
    function 
apertura ($manejador$nombres$atributos) {
    echo 
"hola";
    }
    function 
cierre ($manejador$elemento) {
    
// aun pendiente de terminar... muuuy pendiente
    
echo "cierre";
    }
    
xml_set_element_handler($manejador'apertura''cierre');
    
xml_parser_set_option($manejadorXML_OPTION_CASE_FOLDINGfalse);
    
    foreach (
$documento as $linea) { 
   if (!
xml_parse($manejador$linea)) { 
       die(
sprintf('<br /><span style="color:#f00;">Error al interpretar: %s en la línea %d</span>'
                   
xml_error_string(xml_get_error_code($manejador)), 
                   
xml_get_current_line_number($manejador))); 
   } 
    }
    
xml_parser_free($manejador);
?>
</body>
</html>
__________________
Alex Concha
Buayacorp - Programación y Diseño

Última edición por xknown; 14/02/2005 a las 08:37