mirror of
https://gitee.com/egzosn/pay-java-parent.git
synced 2026-05-17 04:02:52 +08:00
修复http请求工具:ContentType为空的情况,修复多层xml解析问题
This commit is contained in:
@@ -85,12 +85,12 @@ public class XML {
|
||||
while (it.hasNext()) {
|
||||
Element e = (Element) it.next();
|
||||
String k = e.getName();
|
||||
String v = "";
|
||||
Object v = "";
|
||||
List children = e.getChildren();
|
||||
if (children.isEmpty()) {
|
||||
v = e.getTextNormalize();
|
||||
} else {
|
||||
v = getChildrenText(children);
|
||||
v = getChildren(children);
|
||||
}
|
||||
m.put(k, v);
|
||||
}
|
||||
@@ -129,6 +129,32 @@ public class XML {
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子结点的xml
|
||||
*
|
||||
* @param children 集合
|
||||
* @return String 子结点的xml
|
||||
*/
|
||||
public static Object getChildren(List children) {
|
||||
JSONObject json = new JSONObject();
|
||||
if (!children.isEmpty()) {
|
||||
Iterator it = children.iterator();
|
||||
while (it.hasNext()) {
|
||||
Element e = (Element) it.next();
|
||||
String name = e.getName();
|
||||
String value = e.getTextNormalize();
|
||||
List list = e.getChildren();
|
||||
if (!list.isEmpty()) {
|
||||
json.put(name, getChildren(list));
|
||||
}else {
|
||||
json.put(name, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return json;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将请求参数转换为xml格式的string
|
||||
* @param parameters 请求参数
|
||||
|
||||
Reference in New Issue
Block a user