--enable-ftp \
--with-mysql \
--with-pgsql=shared \
--with-gd=shared \
--witch-apxs=/usr/local/apache/bin/apxs
[bash]# make && make install </pre> Y ahora vamos con un ejemplillo sencillísimo:
prueba.xml <pre>
<?xml version="1.0"?>
<frases>
<frase>Hola a todos. <negrita>Ferdy</negrita></frase>
<frase>Adios a todos.<cursiva>Ferdy</cursiva></frase>
</frases> </pre>
prueba.php <pre>
<html>
<head>
<title>Prueba con XML</title>
</head>
<body bgcolor="#FFFFFF">
<?php
$fichero = "prueba.xml";
$inicio = array(
"FRASES" => "<ul>",
"FRASE" => "<li>",
"NEGRITA" => "<b>",
"CURSIVA" => "<i>"
);
$fin = array(
"FRASES" => "</ul>",
"FRASE" => "</li>",
"NEGRITA" => "</b>",
"CURSIVA" => "</i>"
);
function inicio ( $parser , $nombre , $attrs = "" )
{
if (isset($GLOBALS['inicio'][$nombre]))
{
echo $GLOBALS['inicio'][$nombre];
}
return;
}
function fin ( $parser , $name , $attrs = "" )
{
if (isset($GLOBALS['fin'][$nombre]))
{
echo $GLOBALS['fin'][$nombre];
}
return;
}
function datos ( $parser , $dat )
{
echo $dat;
return;
}
$xml = xml_parser_create();
xml_set_element_handler($xml,"inicio",&q uot;fin");
xml_set_character_data_handler($xml,"datos&qu ot;);
$ret = xml_parse_from_file($xml,$fichero);
if (!$ret)
{
die(sptrinf("XML Error: %s en la línea %d de %s",
xml_error_string(xml_get_error_code($xml)),
xml_get_current_line_number($xml),
$fichero));
}
xml_parser_free($xml);
function xml_parse_from_file($parser,$fichero)
{
if (!($fp = fopen($fichero,"r")))
{
die("No se pudo encontrar el fichero de datos XML: $fichero");
return false;
}
while ($dat = fread($fp,4096))
{
if (!xml_parse($parser,$dat,feof($fp)))
{
fclose($fp);
return false;
}
}
fclose($fp);
return true;
}
?> </pre> Bueno, espero que os sirvan ;)
Salu2.Feliz Codding
![apachar ojo](http://static.forosdelweb.com/fdwtheme/images/smilies/wink.png)
- Fernando Pereda ( Ferdy )
<center><a href="http://www.ferdyx.org/firmas.php"><img src="http://www.ferdyx.org/reg_tira.jpg" border="0"></a></center>