Este codigo es en php, bajando la lista del sistema de calificaciones de la UAA como lista.xsl.
<?php
$data = file_get_contents('lista.xsl');
$dom = new domDocument;
@$dom->loadHTML($data);
$dom->preserveWhiteSpace = false;
$tables = $dom->getElementsByTagName('table');
$datos= array();
$table = $tables->item(1);
$rows = $table->getElementsByTagName('tr');
$table= array();
foreach ($rows as $row) {
$cols = $row->getElementsByTagName('td');
foreach ($cols as $col)
array_push($table, $col->nodeValue);
}
array_push($datos,$table);
$table = $tables->item(2);
$rows = $table->getElementsByTagName('tr');
$table= array();
foreach ($rows as $row) {
$cols = $row->getElementsByTagName('td');
$item = array();
$item[trim($cols->item(0)->nodeValue)]=trim($cols->item(1)->nodeValue);
array_push($table, $item);
}
array_push($datos,$table);
print_r($datos);
//print_r(json_encode($datos));
?>
No comments:
Post a Comment