1.引入pom依赖
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20180130</version>
</dependency>
2.需要转换的xml代码示例
<?xml version="1.0" encoding="utf-8" ?>
<returnsms>
<returnstatus>Success</returnstatus>
<message>ok</message>
<remainpoint>9118</remainpoint>
<taskID>4197401</taskID>
<successCounts>1</successCounts>
</returnsms>
3.java 代码并取值
org.json.JSONObject object = XML.toJSONObject(result);
//xml根节点
String jsonData = object.get("returnsms").toString();
//转换成json对象
JSONObject jsonObject = JSON.parseObject(jsonData);
//取出对应的value
String message = jsonObject.getString("message");