AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Download yahoo weather com8/20/2023 ![]() This data is stored in the Forecast object. I would also like to point out that the feed returns the forecast for today and tomorrow. The TemperatureUnits used in the Weather constructor will decide the units of all the other returned data, so if you use TemperatureUnits.Celcius, the data returned will be in Metric units and if you use TemperatureUnits.Fahrenheit, the data returned will be in Standard units. It is where I got all my information from and it's the source of most of the commenting in the code. Have a look at Yahoo! Weather RSS Feed Documentation Page. The Refresh() method is called in the Weather constructor so you don't need to explicitly call it unless you wish to refresh the forecast data. The basic approach is to get the RSS feed, parse out the relevant data using XmlTextReader and load the parsed data into the custom objects/properties - performing any conversions as necessary. Have a look at the source code, it's well-commented and should be easy to figure out what's going on in there. The method in the Weather class that does all the work is the Refresh() method. I think it might be a bit of an overkill to have enumerated all of the Units like this, but I'm hoping to get around to adding support for other units of measurement as well as conversion between them. As you can see, I have enumerated the Temperature Units to make the code simpler. Here, LOCATIONID is the Location Id that you get from the Yahoo! Weather Website (see above). To create a new Weather object, simply use the following: It's the object you'll create when using the Library. ![]() The bulk of the code consists of objects to hold the data returned by the RSS feed. I have included the XML Documentation generated by Visual Studio as well. The code should be pretty straightforward to use and is well documented. Once I started writing the code for the weather conditions, I figured I'd wrap it up in a Class Library for use in other projects. I was writing a program that reads the current weather conditions to the user using text to speech and I needed a simple way to access this information from my application. To get your local forecast, you need to find the Location ID from the Yahoo! Weather Website by searching for your city/town and getting the Location ID from the URL in the address bar. I have enumerated various variables in an attempt to make the library simpler to use - I hope I haven't taken it too far. I have created various objects to wrap the functionality provided by the Yahoo! Weather RSS Feed. The library is meant to simplify getting the current weather conditions (as well as a 2 day forecast) into your. This is my first Code Project article and I hope everyone likes it. Download demo project and source files - 43.1 KB.
0 Comments
Read More
Leave a Reply. |