Document doc = new Document(new Element(GET_WORKLIST_RESPONE, WORKFLOW_NAMESPACE));
doc.getRootElement().addContent(new Element("totalCount", WORKFLOW_NAMESPACE).setText((String) workList.get(0)));
for (int i = 1; i < workList.size(); i++) {
WorkList wl = (WorkList) workList.get(i);
Element element = new Element("workList", WORKFLOW_NAMESPACE);
element.addContent(new Element("endpoint", WORKFLOW_NAMESPACE).setText(wl.getEndpoint()));
element.addContent(new Element("instanceId", WORKFLOW_NAMESPACE).setText(wl.getInstanceId()));
element.addContent(new Element("rootInstanceId", WORKFLOW_NAMESPACE).setText(wl.getRootInstanceId()));
element.addContent(new Element("taskId", WORKFLOW_NAMESPACE).setText(wl.getTaskId()));
element.addContent(new Element("tracingTag", WORKFLOW_NAMESPACE).setText(wl.getTracingTag()));
element.addContent(new Element("title", WORKFLOW_NAMESPACE).setText(wl.getTitle()));
element.addContent(new Element("defName", WORKFLOW_NAMESPACE).setText(wl.getDefName()));
element.addContent(new Element("startDate", WORKFLOW_NAMESPACE).setText(wl.getStartDate()));
element.addContent(new Element("duplicateTaskCount", WORKFLOW_NAMESPACE).setText(wl.getDuplicateTaskCount()));
element.addContent(new Element("info", WORKFLOW_NAMESPACE).setText(wl.getInfo()));
doc.getRootElement().addContent(element);
}
Element returnElement = doc.getRootElement();