private void query ( String zipcode ) { /* Setup YQL query statement using dynamic zipcode. The statement searches geo.places for the zipcode and returns XML which includes the WOEID. For more info about YQL go to: http://developer.yahoo.com/yql/ */ String qry = URLEncoder . encode ( "SELECT woeid FROM geo.places WHERE text=" + zipcode + " LIMIT 1" ) ; // Generate request URI using the query statement URL url ; try { // get URL content url = new URL ( "http://query.yahooapis.com/v1/public/yql?q=" + qry ) ; URLConnection conn = url . openConnection ( ) ; InputStream content = conn . getInputStream ( ) ; parseResponse ( content ) ; } catch ( MalformedURLException e ) { e . printStackTrace ( ) ; } catch ( IOException e ) { e . printStackTrace ( ) ; } }
Query zipcode from Yahoo to find associated WOEID