I have this code written to snatch some weather data and make it available on my website:
if( ! $xml = simplexml_load_file('http://www.weather.gov/data/current_obs/KBED.xml') )
{
echo 'unable to load XML file';
}
else
{
$temp = $xml->temp_f.' Degrees';
$wind = $xml->wind_mph;
$wind_dir = $xml->wind_dir;
$gust = $xml->wind_gust_mph;
$time = $xml->observation_time;
$pres = $xml->pressure_in;
$weath = $xml->weather;
}
And then I just repeat them inside the tags that I want them inside. My site is low in traffic, but I am wondering what the “best” way to do something like this is if I sway in traffic. Do I have to write these variables that I want to get to the database every hour (when the XML is updated) with a cron job to save the pinging server every time, or is this not a bad practice? I understand that this is a bit subjective, but I no longer need to ask for "better ways." Thanks!!