标签:
URL httpUrl = new URL(url); HttpURLConnection conn = (HttpURLConnection )httpUrl.openConnection(); conn.setRequestMethod("GET"); conn.setReadTimeout(5000); InputStream in = conn.getInputSteam(); XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); XmlPullParser parser = factory.newPullParser(); parser.setInput(in,"UTF-8"); int eventType = parser.getEventType(); final List<Girl> list = new ArrayList<Girl>(); Girl girl = null; while(eventType != XmlPullParser.END_DOCUMENT){ String data = parser.getName(); swich(eventType){ case XmlPullParser.START_TAG: if("gril".equals(data)){ girl = new Girl(); } if("name".equals(data)){ girl.setName(parser.nextText()); } break; case XmlPullParser.END_TAG: if("girl".equals(data)&&girl != null){ list.add(girl); } bradk; } eventType = parser.next(); }
标签:
原文地址:http://www.cnblogs.com/luoxiaolei/p/5186085.html