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í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($manejador, XML_OPTION_CASE_FOLDING, false);
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>