php-domcontent-schnipseltest.php


Quell Code


<?php 
header('Content-type: text/plain');
$unwetter_html=file_get_contents('http://www.wettergefahren.de/DWD/warnungen/warnapp/warnings.html');
file_put_contents('unwetter_warnungen.html',$unwetter_html);
$oDom = new DOMDocument;
@$oDom->loadHTML($unwetter_html); 
$e=0;
$r=0;
$oDomElement = $oDom->getElementsByTagName( 'h2' ); 
foreach ($oDomElement as $oDomNode1){
    echo $e.' = '.$oDomNode1->nodeValue;
    echo '<hr>';
    $ee=$oDom->getElementsByTagName('table')->item($e)->getElementsByTagName('td');//->nodeValue; 
     //$ee1=$oDom->getElementsByTagName('td');
    echo '<table><tr>';
    foreach ($ee as $td ) {
         echo ''.$r.'<td>'.$td->nodeValue.'</td>';
         if($r%=4){
              echo '</tr><tr>\n';
         }  
         $r++;
    }
$e++;
echo '</tr></table>\n\n<br><hr><br>';
} 
?>