NodeList positions = root.getElementsByTagName("position");
if (positions != null && positions.getLength() > 0) {
LOG.debug("Positions count " + positions.getLength());
positionsArr = new Position[positions.getLength()];
for (int i = 0; i < positions.getLength(); i++) {
Position positionnObj = new Position();
Element positionEl = (Element) positions.item(i);
String pid = XMLParseUtil.getElementData(positionEl, "id");
if (pid != null) {
positionnObj.setPositionId(pid);
}
String title = XMLParseUtil.getElementData(positionEl,
"title");
if (title != null) {
positionnObj.setTitle(title);
}
String isCurrent = XMLParseUtil.getElementData(positionEl,
"is-current");
if (isCurrent != null) {
positionnObj.setCurrentCompany(Boolean
.valueOf(isCurrent));
}
NodeList sd = positionEl.getElementsByTagName("start-date");
if (sd != null && sd.getLength() > 0) {
String year = XMLParseUtil.getElementData(
(Element) sd.item(0), "year");
if (year != null) {
DateComponents comp = new DateComponents();
comp.setYear(Integer.parseInt(year));
positionnObj.setStartDate(comp);
}
}
NodeList ed = positionEl.getElementsByTagName("end-date");
if (ed != null && ed.getLength() > 0) {
String year = XMLParseUtil.getElementData(
(Element) ed.item(0), "year");
if (year != null) {
DateComponents comp = new DateComponents();
comp.setYear(Integer.parseInt(year));
positionnObj.setEndDate(comp);
}
}
NodeList companyNodes = positionEl
.getElementsByTagName("company");
if (companyNodes != null && companyNodes.getLength() > 0) {
Element company = (Element) companyNodes.item(0);
String compid = XMLParseUtil.getElementData(company,
"id");
if (compid != null) {
positionnObj.setCompanyId(compid);
}
String compName = XMLParseUtil.getElementData(company,
"name");
if (compName != null) {
positionnObj.setCompanyName(compName);
}
String industry = XMLParseUtil.getElementData(company,
"industry");
if (industry != null) {
positionnObj.setIndustry(industry);
}
String type = XMLParseUtil.getElementData(company,
"type");
if (type != null) {
positionnObj.setCompanyType(type);
}
}
positionsArr[i] = positionnObj;
}
}