前端之家收集整理的这篇文章主要介绍了
解析微信返回的xml到map中,
前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
public static Map<String,String> parseXml(HttpServletRequest request) throws Exception {
Map<String,String> map = new HashMap<String,String>();
InputStream inputStream = request.getInputStream();
System.out.println(inputStream.toString());
SAXReader reader = new SAXReader();
Document document = reader.read(inputStream);
Element root = document.getRootElement();
List<Element> elementList = root.elements();
for (Element e : elementList)
map.put(e.getName(),e.getText());
inputStream.close();
inputStream = null;
return map;
}
原文链接:https://www.f2er.com/xml/294642.html