List comments = new ArrayList();
Element commentsElement = response.getPayload();
NodeList commentNodes = commentsElement.getElementsByTagName("comment");
int n = commentNodes.getLength();
for (int i = 0; i < n; i++) {
Comment comment = new Comment();
Element commentElement = (Element) commentNodes.item(i);
comment.setId(commentElement.getAttribute("id"));
comment.setAuthor(commentElement.getAttribute("author"));
comment.setAuthorName(commentElement.getAttribute("authorname"));
comment.setPermaLink(commentElement.getAttribute("permalink"));
long unixTime = 0;
try {
unixTime = Long.parseLong(commentElement.getAttribute("datecreate"));
} catch (NumberFormatException e) {
// what shall we do?
e.printStackTrace();
}
comment.setDateCreate(new Date(unixTime * 1000L));
comment.setText(XMLUtilities.getValue(commentElement));
comments.add(comment);
}
return comments;
}