//Parsal $markers = simplexml_load_file('http://www.meteo.gr/WFSail/templates/Gdata2.xml'); foreach ($markers->GROUND_STATIONS as $pogoda) { $tmp = $pogoda->attributes(); $tmp['station_name']; $tmp['station_id']; $tmp['od_date']; $tmp['od_time']; $tmp['lat']; $tmp['long']; } // odbieramy dane z xml dane stacji $station_name = $tmp['station_name']; $station_id = $tmp['station_id']; $od_date=$tmp['od_date']; $od_time=$tmp['od_time']; $lat = $tmp['lat']; $lng = $tmp['long']; foreach ($pogoda->OBSERVATIONS_GREECE as $rozne){ $tmp = $rozne->attributes(); $tmp['wind_dir']; $tmp['wind_force']; $tmp['temperature']; $tmp['pressure']; } //Odbieramy dane z pliku xml dane pomiaru $wind_dir=$tmp['wind_dir']; $wind_force=$tmp['wind_force']; $temperature=$tmp['temperature']; $pressure=$tmp['pressure']; foreach ($rozne->OBSERVATIONS_PHENOMENA as $tekst){ $tmp = $tekst->attributes(); $tmp['DIRTEXT']; $tmp['descr']; } //Odbieramy dane z pliku xml dane pomiaru czesc druga $DIRTEXT=$tmp['DIRTEXT']; $descr=$tmp['descr']; if($station_name and $station_id and $od_date and $od_time and $lat and $lng and $wind_dir and $wind_force and $temperature and $pressure and $DIRTEXT and $descr) { // łączymy się z bazą danych // dodaje dane stacji do bazy station_name='$station_name',station_id='$station_id',dzien='$od_date',czas='$od_time',lat='$lat',lng='$lng',wind_dir='$wind_dir',wind_force='$wind_forc e',temperature='$temperature',pressure='$pressure',DIRTEXT='$DIRTEXT',descr='$descr'"); }
Problem prawie rozwiązany, tylko teraz dziwnie zapisują mi się dane w tabeli a mianowicie w trzech rekordach są dane z jednej stacji to jest kod
// łšczymy się z bazš danych //Parsal $markers = simplexml_load_file('http://www.meteo.gr/WFSail/templates/Gdata2.xml'); foreach ($markers->GROUND_STATIONS as $pogoda) { $tmp = $pogoda->attributes(); $tmp['station_name']; $tmp['station_id']; $tmp['od_date']; $tmp['od_time']; $tmp['lat']; $tmp['long']; $ins = mysql_query("INSERT INTO nazwa tabeli SET station_name='$station_name',station_id='$station_id',dzien='$od_date',czas='$od_time',lat='$lat',lng='$lng'"); // odbieramy dane z xml dane stacji $station_name = $tmp['station_name']; $station_id = $tmp['station_id']; $od_date=$tmp['od_date']; $od_time=$tmp['od_time']; $lat = $tmp['lat']; $lng = $tmp['long']; foreach ($pogoda->OBSERVATIONS_GREECE as $rozne){ $tmp = $rozne->attributes(); $tmp['wind_dir']; $tmp['wind_force']; $tmp['temperature']; $tmp['pressure']; $ins = mysql_query("INSERT INTO nazwa tabeli SET wind_dir='$wind_dir',wind_force='$wind_force',temperature='$temperature',pressure='$pressure'"); //Odbieramy dane z pliku xml dane pomiaru $wind_dir=$tmp['wind_dir']; $wind_force=$tmp['wind_force']; $temperature=$tmp['temperature']; $pressure=$tmp['pressure']; foreach ($rozne->OBSERVATIONS_PHENOMENA as $tekst){ $tmp = $tekst->attributes(); $tmp['DIRTEXT']; $tmp['descr']; } } } //Odbieramy dane z pliku xml dane pomiaru czesc druga $DIRTEXT=$tmp['DIRTEXT']; $descr=$tmp['descr']; if($station_name and $station_id and $od_date and $od_time and $lat and $lng and $wind_dir and $wind_force and $temperature and $pressure and $DIRTEXT and $descr) { }