Java Reference
In-Depth Information
weather.temp=event.getAttributeValue("temp");
// assemble image
v
ar imgUrl = "http://l.yimg.com/
a
/i/us/we/52/"
"{event.getAttributeValue("code")}.gif";
weather.image = Image{url:imgUrl};
}
if(
event.type
==
PullParser.END_ELEMENT
and
event.qname.name.equals("wind")){
weather.windSpeed=
event.getAttributeValue("speed")
}
if(
event.type
==
PullParser.END_ELEMENT
and
event.qname.name.equals("
atmosphere
")){
weather.visibility=
event.getAttributeValue("visibility");
weather.pressure =
event.getAttributeValue("pressure");
weather.humidity =
event.getAttributeValue("humidity");
}
if(
event.type
==
PullParser.END_ELEMENT
and
event.qname.name.equals("
astronomy
")){
weather.sunriseTime =
event.getAttributeValue("sunrise");
weather.sunsetTime =
event.getAttributeValue("sunset");
}
}
...
}
rss.start();
}
When the code is executed, you will get a weather widget, as shown in the next screenshot.


