Display Local Weather Data On Your Site
page 3 of 7
by Andrew Mooney
Feedback
Average Rating: 
Views (Total / Last 10 Days): 43388/ 65

Current Weather Conditions XML Feeds

XML is a great choice for distributing data. That is probably why the National Weather Service (NWS) has chosen XML as the format to distribute their current weather conditions for about 1,800 locations in the United States. These feeds are updated hourly and come in both XML and RSS formats. The focus of this article will be using the XML feeds to display current local weather conditions on your web site.

The first step is to go to the NWS web site using this link. Once you are at the NWS site, to find your local weather station just select a state and then select the orange and white XML image next to the location that you want to display in the XML column. There are two columns of XML images; the first column contains a link to the RSS file, the second column links to the XML file and that is the one you want. What you are looking for is the four character station ID. In my example I will be using the station ID for Chicago's Midway Airport which is KMDW. Once you click on the link, the XML feed will be displayed in your browser. It will look similar to Listing 1 for Midway Airport. The URL for the XML feed you have chosen will be in your web browser's address bar. You will need to write down or copy and paste this URL so that we can use it when building our web page.

Listing 1 shows a snapshot of an actual XML feed for Chicago's Midway Airport. This snapshot was taken from this URL. The URL you saved should look identical except for the four character station ID. Taking a look at the different nodes in the listing will give you an idea of what current weather conditions can be displayed.

Listing 1 - This is a copy of the XML feed for Chicago's Midway Airport

<?xml version="1.0" encoding="ISO-8859-1" ?>
<current_observation version="1.0" 
xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
xsi:noNamespaceSchemaLocation=
"http://www.weather.gov/data/current_obs/current_observation.xsd">
<credit>NOAA's National Weather Service</credit> 
<credit_URL>http://weather.gov/</credit_URL> 
<image>
<url>http://weather.gov/images/xml_logo.gif</url> 
<title>NOAA's National Weather Service</title> 
<link>http://weather.gov</link> 
</image>
<suggested_pickup>15 minutes after the hour</suggested_pickup> 
<suggested_pickup_period>60</suggested_pickup_period> 
<location>Chicago Midway Airport, IL</location> 
<station_id>KMDW</station_id> 
<latitude>41.47.03N</latitude> 
<longitude>087.45.19W</longitude> 
<observation_time>Last Updated on Jan 5, 7:51 pm CST</observation_time> 
<observation_time_rfc822>Fri, 5 Jan 2007 19:51:00 -0600 CST
</observation_time_rfc822> 
<weather>Overcast</weather> 
<temperature_string>50 F (10 C)</temperature_string> 
<temp_f>50</temp_f> 
<temp_c>10</temp_c> 
<relative_humidity>74</relative_humidity> 
<wind_string>From the North at 6 MPH</wind_string> 
<wind_dir>North</wind_dir> 
<wind_degrees>340</wind_degrees> 
<wind_mph>5.75</wind_mph> 
<wind_gust_mph>NA</wind_gust_mph> 
<pressure_string>29.67" (1005.0 mb)</pressure_string> 
<pressure_mb>1005.0</pressure_mb> 
<pressure_in>29.67</pressure_in> 
<dewpoint_string>42 F (6 C)</dewpoint_string> 
<dewpoint_f>42</dewpoint_f> 
<dewpoint_c>6</dewpoint_c> 
<heat_index_string>NA</heat_index_string> 
<heat_index_f>NA</heat_index_f> 
<heat_index_c>NA</heat_index_c> 
<windchill_string>48 F (9 C)</windchill_string> 
<windchill_f>48</windchill_f> 
<windchill_c>9</windchill_c> 
<visibility_mi>10.00</visibility_mi> 
<icon_url_base>http://weather.gov/weather/images/fcicons/</icon_url_base> 
<icon_url_name>novc.jpg</icon_url_name> 
<two_day_history_url>http://www.weather.gov/data/obhistory/KMDW.html
</two_day_history_url> 
<ob_url>http://www.nws.noaa.gov/data/METAR/KMDW.1.txt</ob_url> 
<disclaimer_url>http://weather.gov/disclaimer.html</disclaimer_url> 
<copyright_url>http://weather.gov/disclaimer.html</copyright_url> 
<privacy_policy_url>http://weather.gov/notice.html</privacy_policy_url> 
</current_observation>

View Entire Article

User Comments

No comments posted yet.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-04-20 7:34:41 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search