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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 246k
  • Answers 246k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can return custom format by returning a Python dictionary.… May 13, 2026 at 8:22 am
  • Editorial Team
    Editorial Team added an answer I believe that there is no real reason (including history,… May 13, 2026 at 8:22 am
  • Editorial Team
    Editorial Team added an answer Looks like this is a bug we're all having. See… May 13, 2026 at 8:22 am

Related Questions

I have an FPGA device with which my code needs to talk. The protocol
I have the following snippet of code written in C#: openFileDialog1.InitialDirectory = \\\\fwm-storage\\users\\ +
I've written an entire app pretty successfully in Django but I have this nagging
I have some delphi code which, given a list of items, calculates the total

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.