List tags = new ArrayList();
String tagsAttr = photoElement.getAttribute("tags");
if (!tagsAttr.equals("")) {
String[] values = tagsAttr.split("\\s+");
for (int i = 0; i < values.length; i++) {
Tag tag = new Tag();
tag.setValue(values[i]);
tags.add(tag);
}
} else {
try {
Element tagsElement = (Element) photoElement.getElementsByTagName("tags").item(0);
NodeList tagNodes = tagsElement.getElementsByTagName("tag");
for (int i = 0; i < tagNodes.getLength(); i++) {
Element tagElement = (Element) tagNodes.item(i);
Tag tag = new Tag();
tag.setId(tagElement.getAttribute("id"));
tag.setAuthor(tagElement.getAttribute("author"));
tag.setRaw(tagElement.getAttribute("raw"));
tag.setValue(((Text) tagElement.getFirstChild()).getData());
tags.add(tag);
}
} catch (IndexOutOfBoundsException e) {
}
}