Скачать xml php

Доброго вечера) Можете подсказать, как правильно сделать проверку "если у нас есть уже такой файл - то спарсить его, если нет - скачать и парсить" У меня сейчас главная проблема в том, что файл не скачивается. Хочу сохранить их в папке xml, которая лежит там же, где и php файл

Код:

        //if(file_exists('xml/'))
        $src = file_get_contents('https://www.yr.no/place/'. $_GET['city'] .'/forecast.xml');
        file_put_contents('xml/', $src);

        $data = new SimpleXMLElement($src);
        $str = $data->forecast->tabular->time;

        foreach ($data->forecast->tabular->time as $str) 
        {
            if(strtotime($_GET["date"]) >= strtotime($str['from']) && strtotime($_GET['date']) <= strtotime($str['to']))
            {
                $forecast["Temperature:"] = (string) $str->temperature["value"];
                $forecast["Precipitation:"] = (string) $str->precipitation["value"];
                $windDirection = $str->windDirection["name"];
                $forecast["Wind:"] = (string) $str->windSpeed["mps"] . " m/s from $windDirection";
                $date = date ("d.m.Y H:i", strtotime($_GET['date']));
                $city = $data->location->name;
                $result = "OK";
                break;
            }
            else  {
                $result = "ERROR";
                $error_message = "Not found";
            }
        }

Ответы (0 шт):