// Learning Processing // Daniel Shiffman // http://www.learningprocessing.com // Example 18-5: Parsing Yahoo's XML weather feed manually // A WeatherGrabber class class WeatherGrabber { int temperature = 0; String weather = ""; String zip; WeatherGrabber(String tempZip) { zip = tempZip; } // Set a new Zip code void setZip(String tempZip) { zip = tempZip; } // Get the temperature int getTemp() { return temperature; } // Get the weather String getWeather() { return weather; } // Make the actual XML request void requestWeather() { // Get all the HTML/XML source code into an array of strings // (each line is one element in the array) String url = "http://xml.weather.yahoo.com/forecastrss?p=" + zip; String[] lines = loadStrings(url); // Turn array into one long String String xml = join(lines, "" ); // Searching for weather condition String lookfor = "