private int parseXML(String address) { try { URL url = new URL(address); XmlPullParserFactory creator = XmlPullParserFactory.newInstance(); XmlPullParser parser = creator.newPullParser(); parser.setInput(url.openStream(), null); Address item = null; String currentTag = null; int event = parser.getEventType(); while (event != XmlPullParser.END_DOCUMENT) { if (event == XmlPullParser.START_TAG) { if (parser.getName().equals("item")) { item = new Address(); } else { currentTag = parser.getName(); } } else if (event == XmlPullParser.TEXT) { String text = parser.getText().trim(); if ((item != null) && (!text.equals(""))) { item.setField(currentTag, text); } } else if ((event == XmlPullParser.END_TAG) && ((parser.getName().equals("item")))) { data.add(item); } event = parser.next(); } return adapter.getCount(); } catch(Exception ex) { Log.e (“MyTAG”, "Error: " + ex.toString(), ex); return -1; } } }