Parse XML on Android

前端 未结 3 1769
广开言路
广开言路 2020-12-20 06:06

I am trying to use the API for our billing system in an Android Application, but I am having trouble figuring out how to parse the XML that it returns. Here is what my funct

3条回答
  •  無奈伤痛
    2020-12-20 07:02

    1. Add java-json.jar in library folder
    2. Compile files ('libs/java-json.jar') //add this line into your build

    Here is the code to convert xml response to json response:

    JSONObject jsonObj = null;
    try {
            jsonObj = XML.toJSONObject(response.toString());
    } catch (JSONException e) {
            Log.e("JSON exception", e.getMessage());
            e.printStackTrace();
    }
    

提交回复
热议问题