android xmlreader解析器

SAXParserFactory spf = SAXParserFactory.newInstance();
            SAXParser sp = spf.newSAXParser();

            XMLReader xr = sp.getXMLReader();

            GoogleWeatherHandler gwh = new GoogleWeatherHandler();
            xr.setContentHandler(gwh);

            InputStreamReader isr = new InputStreamReader(url.openStream(), "GBK");
            InputSource is = new InputSource(isr);

            xr.parse(is);

            WeatherSet ws = gwh.getMyWeatherSet();

            updateWeatherInfoView(R.id.weather_0, ws.getMyCurrentCondition());
            updateWeatherInfoView(R.id.weather_1, ws.getMyForecastConditions().get(0));
            updateWeatherInfoView(R.id.weather_2, ws.getMyForecastConditions().get(1));
            updateWeatherInfoView(R.id.weather_3, ws.getMyForecastConditions().get(2));
            updateWeatherInfoView(R.id.weather_4, ws.getMyForecastConditions().get(3));

posted on 2012-03-07 23:24  larryle  阅读(1083)  评论(0)    收藏  举报