org.dom4j.Element pubsubElement = result.setChildElement("pubsub", "http://jabber.org/protocol/pubsub");
org.dom4j.Element itemsElement = pubsubElement.addElement("items");
itemsElement.addAttribute("node", PEPActivityHandler.NODE);
for (ActivityEntry entry : activities) {
Element entryElement = (Element) domDocument.appendChild(domDocument.createElementNS(Atom.NAMESPACE, Atom.ENTRY_ELEMENT));
writer.write(entry, entryElement);
domDocument.removeChild(entryElement);
org.dom4j.Element itemElement = itemsElement.addElement("item");
itemElement.addAttribute("id", entry.getId());
itemElement.add((org.dom4j.Element) entryElement);