Element root = document.addElement("root");
Element usercontacts = root.addElement("usercontacts");
for (Iterator<UserContacts> it = userContacts.iterator();it.hasNext();) {
UserContacts uc = it.next();
Element usercontact = usercontacts.addElement("usercontact");
usercontact.addElement("userContactId").addCDATA(formatString(""+uc.getUserContactId()));
usercontact.addElement("hash").addCDATA(formatString(""+uc.getHash()));
if (uc.getContact() != null) {
usercontact.addElement("contact").addCDATA(formatString(""+uc.getContact().getUser_id()));
} else {
usercontact.addElement("contact").addCDATA("0");
}
if (uc.getOwner() != null) {
usercontact.addElement("owner").addCDATA(formatString(""+uc.getOwner().getUser_id()));
} else {
usercontact.addElement("owner").addCDATA("0");
}
usercontact.addElement("pending").addCDATA(formatString(""+uc.getPending()));
usercontact.addElement("shareCalendar").addCDATA(formatString(""+uc.getShareCalendar()));
}
return document;
}