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

When the XML Feed Is Unavailable

The most likely thing to cause a problem with displaying our weather conditions is the availability of the weather feed from the NWS. So, we want to plan ahead for that by creating a default XML file that can be loaded if the feed becomes unavailable.

The default XML in my example simple displays a messaging stating that weather information is not currently available. If you look back up at the XSL in Listing 2 you will notice that there is not a test to see if the location and observation time nodes exist. This is because they are in the default XML file. The other nodes are not in the default XML file so the check is made to suppress the labels. As an alternative you could just hide the XML control in the web page or have the XSL display nothing at all.

I have created an example default XML file which is shown in Listing 3. Name the XML file Weather.xml and place it in the App_Data folder of your web application.

Listing 3 - This is the default XML file that will be loaded when the weather feed is unavailable.

<?xml version="1.0" encoding="utf-8" ?>
<current_observation>
  <location>Weather Information</location>
  <observation_time>Is Not Available</observation_time>
</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-2021 ASPAlliance.com  |  Page Processed at 2021-02-25 10:44:10 AM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search