public static Map<String,Object> parseBodyXml2Map(String xml){ Map<String,Object> map = new HashMap<String,Object>(); Document doc = null; try { doc = DocumentHelper.parseText(xml); // 将字符串转为XML Element rootElt = doc.getRootElement(); // 获取根节点 List<Element> list = rootElt.elements();//获取根节点下所有节点 for (Element element : list) { //遍历节点 map.put(element.getName(), element.getText()); //节点的name为map的key,text为map的value } } catch (DocumentException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } return map; }