Creating a Weather Web Part
In many organizations a frequent request is to display the current time and weather for one or more locations where the organization operates.
This exercise provides a great example of how to consume web based data to populate the content. For the purpose of this chapter I am going to consume a service provided by The Weather Channel ®. You will need to register as a partner in order to use this service. You can find additional details at http://portal.theweatherchannel.com/.
Approach
The easiest way to use this service is to load the content into the standard XML Web Part. This approach will also work in cloud-based environments such as Office 365. The XML Viewer Web Part is included under the Content Rollup category as displayed in the following screenshot:
Configuring the XML Web Part
With the XML Web Part added to the page, configure the appearance properties such as title, height, and width. Set the XML link to the path of the service with the required inputs, and set the XSL link to the path of your XSL file. The best way to manage the XSL file is to upload it into a central style and script library on the site.
The contents of the XSL file should format the content into the desired format. The Weather.com web service will return a number of key attributes including the location, the current temperature, and the current time.
Weather Web Part displayed
A rendered version of the Current Weather Web Part is displayed in the following screenshot:
The standard SharePoint Web Parts can also be exported with configuration settings making it easy to reuse the content on many pages or sites. It can either be uploaded to the desired page(s) or added to the site collection's Web Part Gallery.