dom4j递归解析所有子节点
//解析返回的xml字符串,生成document对象
Document document = DocumentHelper.parseText(resultXml);
//根节点
Element root = document.getRootElement();
//子节点
List<Element> childElements = root.elements();
Map<String,Object> mapEle = new HashMap<String, Object>();
//遍历子节点
mapEle = getAllElements(childElements,mapEle);
private Map<String, Object> getAllElements(List<Element> childElements,Map<String,Object> mapEle) {
for (Element ele : childElements) {
mapEle.put(ele.getName(), ele.getText());
if(ele.elements().size()>0){
mapEle = getAllElements(ele.elements(), mapEle);
}
}
return mapEle;
}