Has anyone used XMLElement with JSON and/or Wundergourd.com?
in
Contributed Library Questions
•
1 year ago
Hello,
I'm trying to parse XML weather data from wunderground.com using XMLElement, and it's looking like wunderground's API requires the use of JSON too.
Can anyone shed some light on how to make these come together?
The code below is junk, but I hope that it can give some idea of what I'm trying to accomplish.
import org.json.*;
XMLElement xml;
void setup() {
size(600, 600);
xmlElement xmlFeed = new XMLElement(this, "http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=KILCHICA30");
int numSites = xmlFeed.getChildCount();
for (int i = 0; i < numSites; i++) {
XMLElement current_observations = xml.getChild(i);
XMLElement[] kids = entry.getChildren();
//int id = kid.getInt("1"); //second node
float current_observation = int(kids[0].getContent());
string termp_f = string(kids[1].getContent());
//String url = kid.getString("http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=KILCHICA30");
//String site = kid.getContent();
println(id + " : " + url + " : " + site);
println(current_observation);
println(termp_f);
}
}
1