Hola necesito parsear este html y obtener los datos, y estos datos crear un xml, pero me cuesta llegar a obtenerlos todos y acomodarlos!!!
Estoy usando simplehtmldom y lo bajan de aquí --->
http://simplehtmldom.sourceforge.net/ ![Aplauso](http://static.forosdelweb.com/fdwtheme/images/smilies/aplausos.gif)
;
este es mi HTML el cual necesito convertir en XML
Código HTML:
Ver original <td valign="top" width="200"><div class="titulos_futuro_fisico">FUTURO
</div> <div class="div_columnas"> <table border="0" cellpadding="0" cellspacing="0" width="190"> <td class="tiutlos_col_cuadro_merc_granos">MERCADO
<br></td> <td class="tiutlos_col_cuadro_merc_granos" width="50"><div align="center">POS
<br>
<td class="tiutlos_col_cuadro_merc_granos" width="45"><div align="center">U$S
<br> <td class="tiutlos_col_cuadro_merc_granos" width="50"><div align="right">VAR U$S
<br>
<td width="50"><div align="center">NOV/10
</div></td> <td width="45"><div align="center">379,01
</div></td> <td width="50"><div align="right"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <td><div align="right"><img src="images/iconos/menos.gif" height="7" width="7"></div></td> <td width="33"><div align="right">-4,23
</div></td>
<td width="50"><div align="center">MAY/11
</div></td> <td width="45"><div align="center">381,03
</div></td>
<td width="50"><div align="right"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <td><div align="right"><img src="images/iconos/menos.gif" height="7" width="7"></div></td> <td width="33"><div align="right">-4,41
</div></td>
<td width="50"><div align="center">NOV/10
</div></td> <td width="45"><div align="center">272,80
</div></td> <td width="50"><div align="right"> <table border="0" cellpadding="0" cellspacing="0" width="100%">
<td><div align="right"><img src="images/iconos/mas.gif" height="7" width="7"></div></td>
<td width="50"><div align="center">MAY/11
</div></td> <td width="45"><div align="center">249,90
</div></td> <td width="50"><div align="right"> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <td><div align="right"><img src="images/iconos/mas.gif" height="7" width="7"></div></td>
<td width="10"> </td>
<td valign="top" width="200"><div class="titulos_futuro_fisico">FISICO
</div> <div class="div_columnas"> <table border="0" cellpadding="0" cellspacing="0" width="190"> <td class="tiutlos_col_cuadro_merc_granos">MERCADO
<br></td> <td class="tiutlos_col_cuadro_merc_granos" width="55"><div align="right">PRECIO
<br>
<tr align="center"><td colspan="3" height="100%" valign="middle">Sin Cotización
</td></tr>
aca les dejo el codigo de mi php.
Código PHP:
<?php
//http://simplehtmldom.sourceforge.net/
require("simplehtmldom/simple_html_dom.php");
$url="http://www.fyo.com/includes/cgGetMercadoGranos.asp?grano=1";
$html=file_get_contents($url);
/*** a new dom object ***/
$dom = new domDocument;
/*** load the html into the object ***/
$dom->loadHTML($html);
/*** discard white space ***/
$dom->preserveWhiteSpace = false;
/*** the table by its tag name ***/
$tables = $dom->getElementsByTagName('table');
/*** get all rows from the table ***/
$rows = $tables->item(0)->getElementsByTagName('tr');
/*** loop over the table rows ***/
foreach ($rows as $row)
{
/*** get each column by tag name ***/
$cols = $row->getElementsByTagName('td');
/*** echo the values ***/
echo '<tr>'.$cols->item(0)->nodeValue.'</tr><br/>';
}
?>
Aca simplemente lo que hago es porbar que puedo obtner los datos, pero me esta costando darme cuenta como ordenar los datos para que pueda grabarlos o guardarlos como yo quiera. asi me salen todos desarodenados .
Espero que alguien me pueda ayudar! Gracias por la sabiduría y la ayuda que siempre nos brindan a los desarrolladores de INTERNEEEEERRRRDD!!
abrazo!