private List<Contact> contactsResponseHandle(String data) throws Exception {
List<Contact> contacts = new ArrayList<Contact>();
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
XmlPullParser xpp = factory.newPullParser();
xpp.setInput(new StringReader(data));
int eventType = xpp.getEventType();
String username = null;
String email = null;
while (eventType != XmlPullParser.END_DOCUMENT) {
if (eventType == XmlPullParser.START_TAG && "Contact".equals(xpp.getName())) {
while (true) {
if (eventType == XmlPullParser.END_TAG && "Contact".equals(xpp.getName())) {
break;
}
if (eventType == XmlPullParser.START_TAG && "ContactEmail".equals(xpp.getName())) {
while (true) {
if (eventType == XmlPullParser.END_TAG && "ContactEmail".equals(xpp.getName())) {
break;
}
if (eventType == XmlPullParser.START_TAG && "email".equals(xpp.getName())) {
xpp.next();
email = xpp.getText();
}
xpp.next();
eventType = xpp.getEventType();
}
}
if (eventType == XmlPullParser.START_TAG && "passportName".equals(xpp.getName())) {
xpp.next();
email = xpp.getText();
}
if (eventType == XmlPullParser.START_TAG && "displayName".equals(xpp.getName())) {
xpp.next();
username = xpp.getText();
Contact contact = new Contact(username, email);
contacts.add(contact);
}
xpp.next();
eventType = xpp.getEventType();
}
}
xpp.next();
eventType = xpp.getEventType();
}
return contacts;
}