See Also:http://blog.csdn.net/tao_sun/article/details/12452167
延伸:
/** * 将xml内容封装到Vehicle对象中 * @param resultXML 内容为String格式的xml * @return */ @SuppressWarnings("unchecked") public List<Vehicle> parseResult(String resultXML) { if(null == resultXML) { return null; } List<Vehicle> vehicleList = new ArrayList<Vehicle>(); try { Document document = DocumentHelper.parseText(resultXML); Element root = document.getRootElement(); List<Element> elementList = root.elements(); for (Element e : elementList) { Vehicle vehicle = new Vehicle(); vehicle.setXh(e.elementText("xh")); vehicle.setHpzl(e.elementText("hpzl")); vehicle.setHphm(e.elementText("hphm")); ........ vehicleList.add(vehicle); return vehicleList; } } catch (DocumentException e) { log.error("封装实体对象出错", e); } return vehicleList; }