simpleXmlConverter을 이용하면 쉽게 파싱이 가능한데 duplecated 되었다고 해서 다른 방법으로 해결이 가능한지 찾아보다가 다른 라이브러리를 이용해서 파싱하게되었다.
XmlToJson xmlToJson = new XmlToJson.Builder(response).build();
JSONObject jsonObject = xmlToJson.toJson();
try {
JSONObject json = jsonObject.getJSONObject("response");
JSONObject header = json.getJSONObject("header");
String resultCode = header.optString("resultCode");
if(resultCode.equals("00")){
JSONObject body = json.getJSONObject("body");
JSONObject items = body.getJSONObject("items");
JSONArray array = items.getJSONArray("item");
for(int i=0; i<array.length(); i++){
JSONObject obj = array.getJSONObject(i);
String totalDecide = obj.optString("decideCnt");
String totalDeath = obj.optString("deathCnt");
println(totalDeath+" "+totalDecide);
}
} else{
Toast.makeText(this.getApplicationContext(), "시스템 에러가 발생하였습니다", Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
e.printStackTrace();
}