* Posteo simplemente solo si alguien en el futuro tiene la misma duda, y no ha encontrado solucion :P :P
Bueno , como no pude descargar el Manual en Español en formato XML , en el cvs ese , no estan todos los archivos buuu ...
No me quedo otra que Parsear cada documento HTML, quitar a lo menos la cabezera y pies, y solo dejar el contenido de almedio. Luego meter esos datos en un archivo simple xml que me servia para mis propositos.
Código PHP:
<?
// Vamos a Parsear Contenido HTML
// ********************************************************
// Tiempo de Ejecucion
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$tiempoinicial = $mtime;
// ********************************************************
$ruta='C:\\Programas\\Internet\\EasyPHP1-8\\www\\php\\html\\';
$dir=dir($ruta);
$j=0;
function generarxml($archivo,$datos)
{
$archivo=str_replace(".html",".xml",$archivo);
$datos['articulo']=str_replace("&","&",$datos['articulo']);
$datos['articulo']=str_replace("<","<",$datos['articulo']);
$datos['articulo']=str_replace(">",">",$datos['articulo']);
$datos['articulo']=str_replace("'","'",$datos['articulo']);
$datos['articulo']=str_replace('"',""",$datos['articulo']);
$xml='<?xml version="1.0" encoding="iso-8859-1"?>
<channel>
<titlemain>'.utf8_decode($datos["titulo"]).'</titlemain>
<language>es-cl</language>
<autor>http://deerme.org</autor>
<home_title>'.utf8_decode($datos["home"]["title"]).'</home_title>
<home_url>'.utf8_decode($datos["home"]["url"]).'</home_url>
<up_title>'.utf8_decode($datos["up"]["title"]).'</up_title>
<up_url>'.utf8_decode($datos["up"]["url"]).'</up_url>
<prev_title>'.utf8_decode($datos["prev"]["title"]).'</prev_title>
<prev_url>'.utf8_decode($datos["prev"]["url"]).'</prev_url>
<next_title>'.utf8_decode($datos["next"]["title"]).'</next_title>
<next_url>'.utf8_decode($datos["next"]["url"]).'</next_url>
<apex>'.utf8_decode($datos["apendice"]).'</apex>
<description><![CDATA['.utf8_decode($datos["articulo"]).']]></description>
</channel>';
// Generamos el Archivo
$ruta='C:\\Programas\\Internet\\EasyPHP1-8\\www\\php\\xml\\';
if ($file = fopen($ruta.$archivo, "w"))
{
fputs($file, $xml);
fclose($file);
}
}
while ( $elemento = $dir->read() )
{
// Evitamos el . y ...
if ( ($elemento != '.') and ($elemento != '..'))
{
if ( is_file($ruta.$elemento) )
{
$leer = fopen($ruta.$elemento,"r");
$i='0';
while( !feof($leer) )
{
$texto = $texto . fgets($leer,4096);
$i++;
}
fclose($leer);
$texto=str_replace("\n"," ",$texto);
$texto=str_replace("\r"," ",$texto);
//**************
// Titulo
if (eregi("<TITLE >(.*)</TITLE >", $texto, $title))
{
$archivo['titulo']= $title[1];
$is_title = true;
}
//**************
// Home
// <LINK REL="HOME" TITLE="Manual de PHP" HREF="index.html">
if ( preg_match('|<LINK REL="HOME" TITLE="(.*?)" HREF="(.*?)">|is', $texto, $title) )
{
$archivo['home']['title']=$title[1];
$archivo['home']['url']=$title[2];
}
// UP
// <LINK REL="UP" TITLE="Sobre el manual" HREF="about.html">
if ( preg_match('|<LINK REL="UP" TITLE="(.*?)" HREF="(.*?)">|is', $texto, $title) )
{
$archivo['up']['title']=$title[1];
$archivo['up']['url']=$title[2];
}
// Prev
// <LINK REL="PREVIOUS" TITLE="Como ayudar a mejorar la documentación" HREF="about.howtohelp.html">
if ( preg_match('|<LINK REL="PREVIOUS" TITLE="(.*?)" HREF="(.*?)">|is', $texto, $title) )
{
$archivo['prev']['title']=$title[1];
$archivo['prev']['url']=$title[2];
}
// Next
// <LINK REL="NEXT" TITLE="Traducciones" HREF="about.translations.html">
if ( preg_match('|<LINK REL="NEXT" TITLE="(.*?)" HREF="(.*?)">|is', $texto, $title) )
{
$archivo['next']['title']=$title[1];
$archivo['next']['url']=$title[2];
}
// Apendice
// <TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >Apéndice R. Sobre el manual</TD >
if ( preg_match('|<TD WIDTH="80%" ALIGN="center" VALIGN="bottom" >(.*?)</TD >|is', $texto, $title) )
{
$archivo['apendice']=$title[1];
}
// Cuerpo del Mensaje
// <H1 ...... </DIV ><DIV CLASS="NAVFOOTER" >
if ( preg_match('|<H1 >(.*?)</DIV ><DIV CLASS="NAVFOOTER" >|is', $texto, $title) )
{
$archivo['articulo']=$title[1];
$archivo['articulo']=str_replace('</DIV ><DIV CLASS="NAVFOOTER" >','',$archivo['articulo']);
}
elseif ( preg_match('|<H1 CLASS="sect1" >(.*?)</DIV ><DIV CLASS="NAVFOOTER" >|is', $texto, $title) )
{
$archivo['articulo']=$title[1];
$archivo['articulo']=str_replace('</DIV ><DIV CLASS="NAVFOOTER" >','',$archivo['articulo']);
}
elseif ( preg_match('|<HR ALIGN="LEFT" WIDTH="100%">(.*?)<HR ALIGN="LEFT" WIDTH="100%">|is', $texto, $title) )
{
$archivo['articulo']=$title[1];
}
//print_r($archivo);
generarxml($elemento,$archivo);
}
}
$texto="";
$j++;
}
// ******* Estadistica
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$tiempofinal = $mtime;
$tiempototal = ($tiempofinal - $tiempoinicial);
echo $tiempototal;
// ********************************************************
?>
Lo cual crea XML con el Formato
Código:
<?xml version="1.0" encoding="iso-8859-1"?>
<channel>
<titlemain>Como encontrar más información sobre PHP</titlemain>
<language>es-cl</language>
<autor>http://deerme.org</autor>
<home_title>Manual de PHP</home_title>
<home_url>index.html</home_url>
<up_title>Sobre el manual</up_title>
<up_url>about.html</up_url>
<prev_title>Versiones de PHP documentadas en este manual</prev_title>
<prev_url>about.phpversions.html</prev_url>
<next_title>Como ayudar a mejorar la documentación</next_title>
<next_url>about.howtohelp.html</next_url>
<apex>Apéndice R. Sobre el manual</apex>
<description><![CDATA[&lt;A NAME="about.more" &gt;Como encontrar más información sobre PHP&lt;/A &gt;&lt;/H1 &gt;&lt;P &gt;&#13; Este manual no pretende explicar practicas generales de programación. Si vas a empezar a programar ó eres un programador principiante, seguramente tendras dificultades para aprender a programar en PHP usando solamente este manual. Te será de gran ayuda utilizar otros textos más orientados a principiantes. Una lista con libros sobre PHP puede encontrarse en &lt;A HREF="http://www.php.net/books.php" TARGET="_top" ]]></description>
</channel>
Lo cual de manera local, se demoro a lo menos 153 Segundos en parsear 5000 Archivos HTML y crear 5000 Archivos XML simples con esa estructura que defini :P, con lo cual pude crear mi objetivo lo cual era Insertar el
Manual de PHP sin perder el Formato dentro de mi Sitio Web.
Saludos y ojala a alguien le sirva alguna vez la duda que yo tube hace varios dias atras. Muaks