< >

php-domcontent-schnipseltest.php


Quell Code


<?php
$unwetter_html=file_get_contents('http://www.wettergefahren.de/DWD/warnungen/warnapp/warnings.html');
file_put_contents('unwetter_warnungen.html',$unwetter_html);

//readfile('unwetter_warnungen.html');


/*
$oDom = new DOMDocument;
@$oDom->loadHTML($unwetter_html); 
// letzte aktuzaliesiereung
$wann = $oDom->getElementById( 'wettertab' ); 
$ee=$wann->getElementsByTagName('p')->item(0)->nodeValue; 
echo $ee;

// landkreis
echo "<select id='landkreiss'>";
$oDomElement = $oDom->getElementsByTagName( 'h1' ); 
foreach ($oDomElement as $oDomNode ) {
    //echo '<strong>'.$oDomNode->nodeValue.'</strong><br>';
    //echo $oDomNode->getAttribute( 'id' );
    $idland=$oDomNode->getAttribute('id');
    echo "<option value='$idland>$oDomNode->nodeValue</option>";
} 
echo "</select>";


// städte
echo "<select id='stadte'>";
$oDomElement = $oDom->getElementsByTagName( 'h2' ); 
foreach ($oDomElement as $oDomNode1 ) {
    //echo $oDomNode1->nodeValue.'<br>';
   // echo $oDomNode1->getAttribute( 'id' );
   $idst=$oDomNode1->getAttribute( 'id' );
    echo "<option value='$idst'>$oDomNode1->nodeValue</option>";
} 
echo "</select>";
*/
$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>";
}










/*
             $table = $oDomNode->getElementsByTagName( 'table' ); 
             foreach ($table as $oDomNode1 ) {
                 echo $oDomNode1>item($e)->nodeValue.'<br><br><br>';
             } 
   */
//var_dump($oDomElement);


/*
         @$document = new DOMDocument();
         @$document->loadHTML($unwetter_html);
         $path = new DOMXPath($document);
         $urls = $path->evaluate("/html/body//h1");
         for ($x = 0; $x < $urls->length; $x++) {
             $hrefs[$x] = $urls[$x]->innerHTML;//getAttribute('src');
             var_dump($hrefs);
            // echo $hrefs[$x];
                        //echo $urls->item($x)->removeAttribute('src');
         }
         $path->saveHTML();
        echo $path;
      
       $xmlDoc = new DOMDocument();
$xmlDoc->loadHTML("http://www.wettergefahren.de/DWD/warnungen/warnapp/warnings.html");

$x = $xmlDoc->documentElement;
foreach ($x->childNodes AS $item) {
  print $item->nodeName . " = " . $item->nodeValue . "<br>";
}
       
 */
?>

Add Comment

* Required information
1000
Powered by Commentics

Comments (1)

Gravatar
Admin
Sascha65says...

Die Canvas Balken Uhr ist ja mal Fett