Click here to Skip to main content
6,629,885 members and growing! (21,732 online)
Email Password   helpLost your password?
Languages » VB.NET » General     Intermediate License: The Code Project Open License (CPOL)

Weather Forecast with Yahoo! Weather RSS Feed

By Farhad Siasar Djahantighi 2

A class based on the Yahoo! Weather RSS feed.
VB, Windows, .NET 2.0, Visual Studio, Dev
Version:3 (See All)
Posted:25 Apr 2007
Updated:13 Jul 2009
Views:62,450
Bookmarked:37 times
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
19 votes for this article.
Popularity: 4.68 Rating: 3.66 out of 5
2 votes, 10.5%
1

2
2 votes, 10.5%
3
5 votes, 26.3%
4
10 votes, 52.6%
5

Screenshot - Weather_forecast.jpg

Introduction

Every time I wanted to use a weather forecast for my site, I found it too confusing. Each method I found had problems - some of the weather forecast Web services did not work properly. Eventually I noticed that Yahoo! has an RSS for its weather forecast. I decided to make a program to use that in my site and I created a class for it! I hope it will be useful for others who want to have weather forecasts in their programs.

Yahoo! Weather RSS feed

The Yahoo! Weather RSS feed enables you to get up-to-date weather information for your location. You can save this feed in My Yahoo! or your favorite feed aggregate. You can also incorporate the RSS data into your own Web site or client application. The Yahoo! Weather RSS feed is a dynamically-generated feed that is based on zip code or Location ID.

RSS Request

The Yahoo! Weather RSS feed request follows simple HTTP GET syntax: start with a base URL and then add parameters and values after a question mark (?). Multiple parameters are separated by an ampersand (&). There are two parameters for Weather RSS:

  • p for location
  • u for degrees units (Fahrenheit or Celsius)

RSS Response

The Yahoo! Weather RSS feed is an XML document that conforms to RSS 2.0 specifications. RSS is an XML document containing: a single channel element representing the feed, several elements containing metadata about the feed itself, and one or more item elements describing individual items within the feed. You can find all information about these elements on the Yahoo Developer page here. As it is represented in an XML document, we can convert it to classes by XML Serialization in .NET.

Understanding XML Serialization in the .NET Framework

XML Serialization enables you to convert common language runtime objects into XML documents or streams, and vise versa. XML Serialization makes it possible to convert XML documents into such a meaningful format that all programming languages can process the converted documents without any difficulty. You don't need to know much about XML Serialization to use this code, but it can help you to change or customize it yourself.

Using the Code

Using this code is as simple as making an instance of it and then sending its required parameters (Yahoo! Weather RSS parameters) to its constructor. The first parameter is US zip code or Location ID. The second one is Units for temperature. Send "f" for Fahrenheit or "c" for Celsius and then you can use it! Like this:

'//For example we send "IRXX0018" for Location ID of Tehran, and we want 
'//Units for temperature as Fahrenheit
 Dim t As New YahooWeatherForecast("IRXX0018", "f")
 Response.Write(t.rss.channel.item.description)
 Response.Write(t.rss.channel.item.forecast.high)
 Response.Write(t.rss.channel.item.forecast.low)

History

  • 25th April, 2007: Initial post
  • 15th May, 2007 - Updated source file
  • 3rd May, 2008: Updated source file

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Farhad Siasar Djahantighi 2


Member

Location: Iran, Islamic Republic Of Iran, Islamic Republic Of

Other popular VB.NET articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 25 of 54 (Total in Forum: 54) (Refresh)FirstPrevNext
GeneralMy vote of 1 PinmvpDave Kreskowiak9:59 16 Jul '09  
GeneralAdding the Dew Point to your library? Pinmemberrspercy6016:32 14 Jul '09  
GeneralRe: Adding the Dew Point to your library? PinmemberFarhad Siasar Djahantighi19:12 14 Jul '09  
GeneralHeat Index? Pinmemberrspercy6016:46 9 Jul '09  
AnswerRe: Heat Index?.....Answer Pinmemberrspercy6012:17 10 Jul '09  
QuestionHow to get started Pinmembermark lonsbury6:04 4 Apr '09  
AnswerRe: How to get started PinmemberFarhad Siasar Djahantighi19:57 10 Jul '09  
GeneralI got a Ctype Error in VWD 2008 Express. What's wrong with the CType? Pinmembercslamsg23:52 23 Oct '08  
Generalget tomorrows weather Pinmemberbflosabre9110:55 11 Aug '08  
GeneralYahoo! Weather mashup PinmembervirtuPIC21:21 12 May '08  
General"Error in XML Document" Pinmembersayeo876:07 2 May '08  
GeneralRe: "Error in XML Document" PinmemberDan Suthar23:56 2 May '08  
GeneralRe: "Error in XML Document" Pinmemberarashk123:58 2 May '08  
GeneralRe: "Error in XML Document" PinmemberMCofer9:30 11 May '08  
GeneralRe: "Error in XML Document" PinmemberMCofer11:20 11 May '08  
GeneralRe: "Error in XML Document" ...the fix Pinmemberrspercy6012:52 9 Jul '09  
GeneralInput string was not in a correct format Pinmembersuresh00819:33 20 Mar '08  
GeneralRe: Input string was not in a correct format Pinmemberarashk122:45 23 Mar '08  
GeneralMulti Day Forecast Pinmemberbuster9517:52 26 Feb '08  
AnswerRe: Multi Day Forecast Pinmemberfranzil3:19 8 May '08  
GeneralYahoo URL has changed to http://weather.yahooapis.com/forecastrss Pinmembermichael knopf5:12 14 Feb '08  
GeneralVB Express 2005 PinmemberSteve_558:21 23 Oct '07  
GeneralHow to change the language to Chinese ? Pinmembertpang131:37 28 Aug '07  
GeneralAstronomy Class Pinmemberkfwbird14:45 26 Jul '07  
AnswerRe: Astronomy Class Pinmemberarashk110:30 27 Jul '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 13 Jul 2009
Editor: Sean Ewington
Copyright 2007 by Farhad Siasar Djahantighi 2
Everything else Copyright © CodeProject, 1999-2009
Web10 | Advertise on the Code Project