Element root = document.addElement("root");
Element privatemessages = root.addElement("privatemessages");
for (Iterator<PrivateMessages> it = privateMessages.iterator();it.hasNext();) {
PrivateMessages pm = it.next();
Element privateMessage = privatemessages.addElement("privatemessage");
privateMessage.addElement("privateMessageId").addCDATA(formatString(""+pm.getPrivateMessageId()));
privateMessage.addElement("message").addCDATA(formatString(""+pm.getMessage()));
privateMessage.addElement("subject").addCDATA(formatString(""+pm.getSubject()));
privateMessage.addElement("privateMessageFolderId").addCDATA(formatString(""+pm.getPrivateMessageFolderId()));
privateMessage.addElement("userContactId").addCDATA(formatString(""+pm.getUserContactId()));
privateMessage.addElement("parentMessage").addCDATA(formatString(""+pm.getParentMessage()));
privateMessage.addElement("bookedRoom").addCDATA(formatString(""+pm.getBookedRoom()));
if (pm.getFrom() != null) {
privateMessage.addElement("from").addCDATA(formatString(""+pm.getFrom().getUser_id()));
} else {
privateMessage.addElement("from").addCDATA("0");
}
if (pm.getTo() != null) {
privateMessage.addElement("to").addCDATA(formatString(""+pm.getTo().getUser_id()));
} else {
privateMessage.addElement("to").addCDATA("0");
}
privateMessage.addElement("inserted").addCDATA(formatString(""+CalendarPatterns.getDateWithTimeByMiliSeconds(pm.getInserted())));
privateMessage.addElement("isContactRequest").addCDATA(formatString(""+pm.getIsContactRequest()));
privateMessage.addElement("isRead").addCDATA(formatString(""+pm.getIsRead()));
privateMessage.addElement("isTrash").addCDATA(formatString(""+pm.getIsTrash()));
if (pm.getOwner() != null) {
privateMessage.addElement("owner").addCDATA(formatString(""+pm.getOwner().getUser_id()));
} else {
privateMessage.addElement("owner").addCDATA("0");
}
if (pm.getRoom() != null) {
privateMessage.addElement("room").addCDATA(formatString(""+pm.getRoom().getRooms_id()));
} else {
privateMessage.addElement("room").addCDATA("0");
}
}