Node nomElement = contactElement.selectSingleNode("nom");
Node prenomElement = contactElement.selectSingleNode("prenom");
List<Node> emailsElement = contactElement.selectNodes("email");
Node descriptionElement = contactElement.selectSingleNode("description");
Contact contact = new Contact();
contact.setNom(nomElement.getText());
contact.setPrenom(prenomElement.getText());
if(descriptionElement != null)
contact.setDescription(descriptionElement.getText());
for (Node emailElement : emailsElement) {
String typeString = emailElement.valueOf("@type");
Email.EMAIL_TYPE type;
if ("personnelle".equals(typeString))
type = Email.EMAIL_TYPE.PERSONNELLE;
else
type = Email.EMAIL_TYPE.PROFESSIONELLE;
String email = emailElement.getText();
Email EmailType = new Email(type, email);
contact.getEmails().add(EmailType);
}
result.add(contact);
}
return result;