Visualize the Yahoo weather data using simpleML. Following is part of the code to get you started. This is the XML in case you forgot:
<yweather:condition text=“Fair” code=“34” temp=“35” date=“Mon, 20 Feb 2006 3:51 pm EST”/>
import simpleML.*;
// Variables for temperature and weather
int temperature = 0;
String weather = "";
void setup() {
// FILL THIS IN HOWEVER YOU LIKE!
}
void draw() {
// FILL THIS IN HOWEVER YOU LIKE!
}
// Function that makes the weather request with a Zip Code
void getWeather(String zip) {
String url = "http://xml.weather.yahoo.com/ forecastrss?p="+zip;
XMLRequest req = new XMLRequest(this,url);
req.makeRequest();
}
void netEvent(XMLRequest ml) { // Get the specific XML content we want
temperature = int(ml.__________("_________","_________"));
weather = ml.___________("__________","__________");
}
One possible solution:
import simpleML.*;
// Variables for temperature and weather
int temperature = 0;
String weather = "";
void setup() {
size(200,200);
XMLRequest xreq = new XMLRequest(this,"http://xml.weather.yahoo.com/forecastrss?p=10025");
xreq.makeRequest();
// FILL THIS IN HOWEVER YOU LIKE!
textFont(createFont("Arial",16,true));
}
void draw() {
background(255);
// FILL THIS IN HOWEVER YOU LIKE!
textAlign(CENTER);
fill(0);
text(temperature + "\n" + weather,100,50);
}
// Function that makes the weather request with a Zip Code
void getWeather(String zip) {
String url = "http://xml.weather.yahoo.com/ forecastrss?p="+zip;
XMLRequest req = new XMLRequest(this,url);
req.makeRequest();
}
void netEvent(XMLRequest ml) { // Get the specific XML content we want
temperature = int(ml.getElementAttributeText("yweather:condition","temp"));
weather = ml.getElementAttributeText("yweather:condition","text");
println(temperature);
println(weather);
}








