protected Customer readCustomer(InputStream is) {
try {
DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.parse(is);
Element root = doc.getDocumentElement();
Customer cust = new Customer();
if (root.getAttribute("id") != null && !root.getAttribute("id").trim().equals(""))
cust.setId(Integer.valueOf(root.getAttribute("id")));
NodeList nodes = root.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
Element element = (Element) nodes.item(i);
if (element.getTagName().equals("first-name")) {
cust.setFirstName(element.getTextContent());
}
else if (element.getTagName().equals("last-name")) {
cust.setLastName(element.getTextContent());
}
else if (element.getTagName().equals("street")) {
cust.setStreet(element.getTextContent());
}
else if (element.getTagName().equals("city")) {
cust.setCity(element.getTextContent());
}
else if (element.getTagName().equals("state")) {
cust.setState(element.getTextContent());
}
else if (element.getTagName().equals("zip")) {
cust.setZip(element.getTextContent());
}
else if (element.getTagName().equals("country")) {
cust.setCountry(element.getTextContent());
}
}
return cust;
}
catch (Exception e) {