org.json.JSONException: Value <?不能将java.lang.String类型的xml转换为


org.json.JSONException: Value <?xml of type java.lang.String cannot be converted to JSONObject

我正在连接MySQL数据库与我的SQLite和Android。我得到JSON对象错误。它抛出了org.json.Exception。

     try
    { 
        JSONObject json_data = new JSONObject(result);
        name=(json_data.getString("name"));
        Toast.makeText(getApplicationContext(), "Name : "+name,
        Toast.LENGTH_SHORT).show();
    }
    catch(Exception e)
    {
        Log.e("Fail 3", e.toString());
    }

查看结果字符串,它不是JSON而是XML文件。

您的响应是XML格式,在您的服务器端使用json_encode(data)