Many times we see websites that read weather from an RSS feed on another site, here I will show you how to read weather onto your site from Yahoo.

How to get the XML from

To read the weather from Yahoo weather you need to send a request as follows:

where p is the location code. In this tutorial I am using “Calcutta/Kolkata, India”, and as you can see the location code or zip code is INXX0028, if you live in the USA you can just use the ZIP code where you are. Next, ‘u’ is the unit in which the weather must be displayed, I chose ‘f’ for Fahrenheit, but if you want you can also choose ‘c’ for Celsius.

The final output

read weather info using yahoo api

The XML response which is returned from Yahoo weather:


The “root” element is “channel” and beneath that we have other elements as well, the only element we want to get from here is the following one:


So let’s have a look at the code we are going to use. I am echoing the result as well as saving data to MySQL database.

Create Database table


Retrieve weather info from XML response and insert them into database and finally show to the user




If you any query please leave a comment.

Software Professional, I am passionate to work on web/enterprise application. For more information please go to about me. You can follow on Twitter. You can be a friend on Facebook or Google Plus or Linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.