Retrieving a Y! Weather RSS Feed

This example demonstrates how to use the Connection Manager and a PHP proxy (to work around XMLHttpRequest's same-domain policy) to retrieve an XML document from the Yahoo! Weather RSS webservice at http://xml.weather.yahoo.com/forecastrss.

Source file and dependencies

Load the YAHOO namespace and Connection Manager source files using the <script> tag:

Callback Object and the Weather RSS

Yahoo! Weather RSS will return an XML document if the transaction is successful. The following callback object with success and failure handlers is used to process the response.

Assemble the Querystring and Initiate the Transaction

The Yahoo! Weather RSS feed requires a simple HTTP GET request, with a base URL and a querystring whose parameters are defined by the webservice's API. In this example, we will use the following parameters:

The following are some example location IDs (do not include the city name):

(Note: For more details on the Y! Weather RSS feed and other location IDs, please visit http://developer.yahoo.com/weather/index.html, where you'll find thorough documentation of this webservice and its API.)

Method getModule retrieves the input values for location and temperature and creates a querystring.

Please enter a U.S. Zip Code or a location ID to get the current temperature. The default is Zip Code 94089 for Sunnyvale, California; its location ID is: USCA1116.

Enter *F* for Fahrenheit or *C* for Celsius temperature unit.