/* Daniel Shiffman               *//* Programming from A to Z       *//* Spring 2006                   *//* http://www.shiffman.net       *//* daniel.shiffman@nyu.edu       */// Searching for an XML Element// Import the necessary librariespackage basics;import java.io.IOException;import org.w3c.dom.*;import a2z.A2ZXMLHelper;public class XMLWeatherGrab {    public static void main (String argv []) throws IOException {    	        // Create a URL object and open an InputStream        A2ZXMLHelper xmlreader = new A2ZXMLHelper("http://xml.weather.yahoo.com/forecastrss?p=USNY0996");                // Call our recursive search function to locate the element we want        Element e = xmlreader.findElement(xmlreader.getRoot(),"yweather:forecast");        // System.out.println(e.toString());                // As long as we find the element        if (e != null) {            // Pull out the attributes we are looking for from that element            String high = e.getAttribute("high");            System.out.println("The high temp is: " + high);            String low = e.getAttribute("low");            System.out.println("The low temp is: " + low);        }                // Looking for latitude        // Note how we have to pull the value out of the Element's child        e = xmlreader.findElement(xmlreader.getRoot(),"geo:lat");        if (e != null) {            Node n = e.getFirstChild();            System.out.println(n.getNodeValue());        }    }        }