$city_id=34214;
$data_file="http://export.yandex.ru/weather-ng/forecasts/$city_id.xml?".rand(); // адрес xml файла
$xml = simplexml_load_file($data_file); // раскладываем xml на массив
$temp=$xml->fact->temperature;
// Если значение температуры положительно, для наглядности добавляем "+"
if ($temp>0) {$temp='+'.$temp;}
sg("Moscow.Temp",$temp);
sg("Moscow.City",Москва);
sg("Moscow.Type",$xml->fact->weather_type);
sg("Moscow.Pressure",$xml->fact->pressure);
sg("Moscow.Humidity",$xml->fact->humidity);
sg("Moscow.WindSpeed",$xml->fact->wind_speed);
sg("Moscow.Image",$xml->fact->image);
sg("Moscow.UpTime",$xml->fact->uptime);
$dir = $xml->fact->wind_direction;
switch ($dir){
case 's':
$dir="южное";
break;
case 'n':
$dir="северное";
break;
case 'w':
$dir="западное";
break;
case 'e':
$dir="восточное";
break;
case 'sw':
$dir="юго-западное";
break;
case 'nw':
$dir="северо-западное";
break;
case 'calm':
$dir="штиль";
break;
}
sg("Moscow.WindDir",$dir);
sg("Moscow.SunRise",$xml->day[0]->sunrise);
sg("Moscow.SunSet",$xml->day[0]->sunset);