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
<tr> <div class="div_columnas"> <table border="0" cellpadding="0" cellspacing="0" width="190"> </tr> <tr> <table border="0" cellpadding="0" cellspacing="0" width="100%"> </tr> </tr> <tr> <table border="0" cellpadding="0" cellspacing="0" width="100%"> </tr> </tr> <tr> <table border="0" cellpadding="0" cellspacing="0" width="100%"> </tr> </tr> <tr> <table border="0" cellpadding="0" cellspacing="0" width="100%"> </tr> </tr> <div class="div_columnas"> <table border="0" cellpadding="0" cellspacing="0" width="190"> </tr> </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!
![borracho](http://static.forosdelweb.com/fdwtheme/images/smilies/borracho.png)