Fixed country parsing

master
Omertron 15 years ago
parent f4f64b5962
commit 47de11b73b

@ -54,18 +54,6 @@ public class MovieDB extends ModelTools {
private List<Person> people = new ArrayList<Person>();
private List<Artwork> artwork = new ArrayList<Artwork>();
/**
* Just return the first country
* @return
*/
public String getCountry() {
if (!countries.isEmpty()) {
Country country = countries.get(0);
return country.getName();
}
return UNKNOWN;
}
public String getPopularity() {
return popularity;
}

@ -136,16 +136,28 @@ public class DOMParser {
subNode = subNodeList.item(nodeLoop);
if (subNode.getNodeType() == Node.ELEMENT_NODE) {
subElement = (Element) subNode;
Country country = new Country();
country.setName(DOMHelper.getValueFromElement(subElement, "name"));
country.setCode(DOMHelper.getValueFromElement(subElement, "code"));
country.setUrl(DOMHelper.getValueFromElement(subElement, "url"));
movie.addProductionCountry(country);
NodeList countryList = subNode.getChildNodes();
for (int i = 0; i < countryList.getLength(); i++) {
Node countryNode = countryList.item(i);
if (countryNode.getNodeType() == Node.ELEMENT_NODE) {
subElement = (Element) countryNode;
Country country = new Country();
country.setName(subElement.getAttribute("name"));
country.setCode(subElement.getAttribute("code"));
country.setUrl(subElement.getAttribute("url"));
System.out.println("Name: " + country.getName());
System.out.println("Code: " + country.getCode());
System.out.println("Url : " + country.getUrl());
movie.addProductionCountry(country);
}
}
}
}
// Process the "cast"
subNodeList = doc.getElementsByTagName("cast");

Loading…
Cancel
Save