Click here to Skip to main content
13,346,708 members (67,094 online)
Click here to Skip to main content
Add your own
alternative version


23 bookmarked
Posted 7 Nov 2008

Weather Using VB.NET and Yahoo RSS!

, 7 Nov 2008
Rate this:
Please Sign up or sign in to vote.
Weather Using VB.NET and Yahoo RSS!


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:

Dim t As New clsWeather("JoXX" & Format(Me.ComboBox1.SelectedIndex + 1, "0000"), "c")

lblHigh.Text = t.high & "ّ"
lblCity.Text = ComboBox1.Items.Item(Me.ComboBox1.SelectedIndex) & " Weather "
lblLow.Text = t.Low & "ّ"
lblDay.Text =
lblCase.Text = t.Case
lblSunrise.Text = t.Sunrise
lblSunset.Text = t.Sunset
lblWInd.Text = CInt(Val(t.Wind)) & " kph"

imgWeather.Image = Image.FromFile(t.GetImage)


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


About the Author

Software Developer (Senior) TeraSoft
Jordan Jordan
This member doesn't quite have enough reputation to be able to display their biography and homepage.
Group type: Collaborative Group (No members)

You may also be interested in...


Comments and Discussions

GeneralMy vote of 1 Pin
deimi1985a6-Nov-13 10:22
memberdeimi1985a6-Nov-13 10:22 
GeneralMy vote of 5 Pin
felchaal4-Jan-12 8:39
memberfelchaal4-Jan-12 8:39 
GeneralMy vote of 3 Pin
I-TECH20115-Dec-11 1:01
memberI-TECH20115-Dec-11 1:01 
GeneralAwesome program! [modified] Pin
Pedro D.23-Apr-10 20:07
memberPedro D.23-Apr-10 20:07 
Greetings Nedal,

Thank you for making this excellent application. I have been looking everywhere, just as you were previously.

I have been trying to get it to display Moscow's weather information, but i've been successful so far. It's still showing the weather data for the default location.

If it helps any, Moscow's Location ID is RSXX0063.

Please help!!


Just to let you know what i've done so far.

I've added a file titled XML.xml replacing the old one, however, this is the XML feed from Moscow.
I've added the clsWeather.vb file to my Project.
I've added the DataSet1.xsd to my Project.

Thus the code is working as you have intended it to work. I'm getting no errors. I just can't get it to display the Moscow information. (It's the only city information I need)

modified on Saturday, April 24, 2010 1:19 AM

Questionexcellent code Pin
Armyman12b15-Apr-09 9:13
memberArmyman12b15-Apr-09 9:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.180111.1 | Last Updated 7 Nov 2008
Article Copyright 2008 by nedal_jo_jo
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid