public static Map
parseSoap(String soap
) throws DocumentException
, DocumentException
{
org
.dom4j
.Document doc
= DocumentHelper
.parseText(soap
);
Element root
= doc
.getRootElement();
Map
<String,Object>map
= new HashMap<String,Object>();
getCode(root
,map
);
return map
;
}
public static void getCode(Element root
, Map
<String, Object> map
) {
if (root
.elements() != null
) {
List
<Element> list
= root
.elements();
for (Element e
: list
) {
if (e
.elements().size() > 0) {
getCode(e
, map
);
}
if (e
.elements().size() == 0) {
map
.put(e
.getName(), e
.getTextTrim());
}
}
}
}
转载请注明原文地址:https://tech.qufami.com/read-14060.html