<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Weather Forcasting</title>
<script type="text/javascript">
var weather={"onReady":false};
function IpWeather()
{
var xmlhttp=false;
if (window.ActiveXObject)
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
else if (!xmlhttp && typeof XMLHttpRequest != 'undefined')
{
xmlhttp = new XMLHttpRequest();
}
xmlhttp.open("GET","http://www.google.com/ig/api?weather=bangalore",true);
// xmlhttp.setRequestHeader("Content-Type", "text/xml");
xmlhttp.send();
xmlhttp.onreadystatechange = function()
{
if (xmlhttp.readyState == 4)
{
var weatherXML = xmlhttp.responseXML;
var now = weatherXML.getElementsByTagName("current_conditions")[0];
var now_t = now.getElementsByTagName('temp_c')[0].getAttribute('data');
var now_w = now.getElementsByTagName('wind_condition')[0].getAttribute('data');
var now_c = now.getElementsByTagName('condition')[0].getAttribute('data');
var now_h = now.getElementsByTagName('humidity')[0].getAttribute('data');
var today = weatherXML.getElementsByTagName("forecast_conditions")[0];
var t_max = today.getElementsByTagName('high')[0].getAttribute('data');
var t_min = today.getElementsByTagName('low')[0].getAttribute('data');
weather={"t_now":now_t,"wind":now_w,"cloud":now_c,"humidity":now_h,"t_max":t_max,"t_min":t_min,"onReady":true};
}
}
}
IpWeather();
</script>
</head>
<body>
<div id='target'></div>
<script type="text/javascript">
function weatherInfo()
{
if(weather.onReady)
{
document.getElementById('target').innerHTML="Weather:"+weather.cloud+" Temperature now:"+weather.t_now+"? whole day between:"+weather.t_min+"--"+weather.t_max+"? "+weather.humidity+" "+weather.wind;
}
else
{
document.getElementById('target').innerHTML="loading....";
// setTimeout("weatherInfo()",10);
}
}
weatherInfo();
</script>
</body>
</html>