import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.XML;
public class XMLUtil2 {
/**
* xml转换json
* @param xml
* @return
* @throws JSONException
*/
public static JSONObject XML2Json(String xml) throws JSONException{
JSONObject xmlJSONObj = null;
try {
xmlJSONObj = XML.toJSONObject(xml);
} catch (JSONException e) {
e.printStackTrace();
}
return xmlJSONObj;
}
/**
* 解析XML
* @return
*/
public static JSONArray SAXXml() {
String xmlString = "";
JSONArray ja = new JSONArray();
try {
JSONObject xml2Json = XML2Json(xmlString);
JSONArray jsonObject = xml2Json.getJSONObject("result").getJSONObject("data").getJSONArray("row");
for (int i = 0; i < jsonObject.length()
soap协议的xml数据转json
最新推荐文章于 2023-12-14 18:01:23 发布