Element root = document.addElement("root");
Element users = root.addElement("users");
for (Iterator<Users> it = uList.iterator();it.hasNext();) {
Users u = it.next();
Element user = users.addElement("user");
user.addElement("age").setText(CalendarPatterns.getDateByMiliSeconds(u.getAge()));
user.addElement("availible").setText(u.getAvailible().toString());
user.addElement("deleted").setText(u.getDeleted());
user.addElement("firstname").setText(u.getFirstname());
user.addElement("lastname").setText(u.getLastname());
user.addElement("login").setText(u.getLogin());
user.addElement("pass").setText(u.getPassword());
String pictureuri = u.getPictureuri();
if (pictureuri != null) user.addElement("pictureuri").setText(pictureuri);
else user.addElement("pictureuri").setText("");
if ( u.getLanguage_id() != null ) user.addElement("language_id").setText(u.getLanguage_id().toString());
else user.addElement("language_id").setText("");
user.addElement("status").setText(u.getStatus().toString());
user.addElement("regdate").setText(CalendarPatterns.getDateWithTimeByMiliSeconds(u.getRegdate()));
user.addElement("title_id").setText(u.getTitle_id().toString());
user.addElement("level_id").setText(u.getLevel_id().toString());
user.addElement("additionalname").setText(u.getAdresses().getAdditionalname());
user.addElement("comment").setText(u.getAdresses().getComment());
//A User can not have a deleted Adress, you cannot delete the Adress of an User
//String deleted = u.getAdresses().getDeleted()
//Phone Number not done yet
user.addElement("fax").setText(u.getAdresses().getFax());
user.addElement("state_id").setText(u.getAdresses().getStates().getState_id().toString());
user.addElement("street").setText(u.getAdresses().getStreet());
user.addElement("town").setText(u.getAdresses().getTown());
user.addElement("zip").setText(u.getAdresses().getZip());
// Email and Phone
user.addElement("mail").setText(u.getAdresses().getEmail());
user.addElement("phone").setText(u.getAdresses().getPhone());
Element user_organisations = user.addElement("organisations");
//List<String> organisations = new LinkedList();
for (Iterator<Organisation_Users> iterObj = u.getOrganisation_users().iterator();iterObj.hasNext(); ) {
Organisation_Users orgUsers = iterObj.next();
user_organisations.addElement("organisation_id").addText(orgUsers.getOrganisation().getOrganisation_id().toString());
}
//Not need at the moment