java 解析接口返回xml类型值



public static Map parseXml(String xml) {
if (StringUtils.isEmpty(xml)) {
return new HashMap();
}
SAXReader saxReader = new SAXReader();
Document document = null;
try {
document = saxReader.read(new ByteArrayInputStream(xml.getBytes("UTF-8")));
} catch (Exception e1) {
log.error("解析调用结果异常", e1);
e1.printStackTrace();
}
// 获取根元素
Element root = document.getRootElement();
Map map = new HashMap();
iterateor(root, map);
return map;
}

你可能感兴趣的:(java)