Getting weather data from XML
in
Programming Questions
•
1 years ago
Hi, I'm new to processing, but code a lot in other languages (C++, Actionscript, and a few others), and I'm writing some code to get the current weather from yahoo. Here is the page the XML data comes from:
And my code:
- XMLElement xml;
- void setup() {
- PFont font;
- size(500,300); //screen size, etc.
- background(0);
- font = loadFont("Arial-Black-48.vlw");
- fill(255);
- textFont(font, 13);
- }
- void draw() {
- if(second() == 0) { //Run every minute (Just for testing, will later run every hour
- String feed = ("http://weather.yahooapis.com/forecastrss?w=24493874&u=c");
- xml = new XMLElement(this,feed);
- background(0);
- XMLElement yweather = xml.getChild("weather"); //I think the problem is here. What should the child be?
- String currweather = yweather.getContent(); //current weather
- }
- }
The error is: "NullPointerException"
I think the problem is on line 23, I don't know what should be in the quotes (I have no xml experience)
The information I hope to get from the XLM data is:
- <yweather:forecast day="Sat" date="26 Nov 2011" low="9" high="10" text="Showers/Wind" code="11"/>
1