Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 239005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:33:03+00:00 2026-05-11T20:33:03+00:00

I have this code written up to snatch some weather data and make it

  • 0

I have this code written up 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 echo them out inside the tags I want them inside. My site is low traffic, but I’m wondering what the “best” way is to do something like this if I were to spike way up in traffic. Should I write those variables I want into a database every hour (when the XML is refreshed) with a cron job to save pinging the server each time, or is that not bad practice? I understand this is a bit subjective, but I have no one else to ask for “best ways”. Thanks!!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:33:03+00:00Added an answer on May 11, 2026 at 8:33 pm
    • Set up a cron job to periodically fetch the XML document, parse it and store the variables in a database.
    • When a page is requested, fetch the variables from the database and render your page.
    • It is a good idea to store the timestamp of the last update in the database as well, so that you can tell when the data is stale (because the weather website is down or so).

    This setup looks very reasonable to me.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am using ajax with jquery .i have written this code: $.ajax({url:myurl.php, data:datastr, type:POST,
jQuery('img').bind('error',function(){ alert('hi'); jQuery(this).hide(); }); I have written this code but non available images are
I have this code: chars = #some list try: indx = chars.index(chars) except ValueError:
I have this code written in .NET 4.0 using VS2010 Ultimate Beta 2: smtpClient.Send(mailMsg);
I have the following assembly code (written for NASM on Linux): ; This code
Hi I have written this code that with output you can get that .remove()
I have written this code but it doesn't compute ((((bY - aY) / (maxX
I have written this code for add cart to payment. while clicking buttons that
I have written this code to view the unread items in my outlook mail
i have written this code and its not working...... indate = 13/1/2011 Calendar cd1

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.