错误分析数据org.json.JSONException:值小于,java.lang.String类型的XML无法转换为JSONArray [英] Error parsing data org.json.JSONException: Value <?xml of type java.lang.String cannot be converted to JSONArray
问题描述
我在写一个应用程序,打算在Android devices.The应用程序运行时supossed读通过PHP MySQL数据库中的信息,但是当我运行该应用程序,登录猫会提示错误错误分析数据org.json。 JSONException:值
在code我得从一个教程下载,请耐心等待,我已经得到了PHP中的一些基本知识,很少在java中。我已经测试了PHP脚本,它是完美的工作,所以我不会刻意去重视它。
I am writing an app intend to run on android devices.The app is supossed to read the information in a Mysql database through php, but when I run the application, Log cat prompts an error 'Error parsing data org.json.JSONException: Value
The code I've got was downloaded from a tutorial, please be patient I've got some basic knowledge in php and very few in java. I already tested the php script and it is working flawlessly, so I won't bother to attach it.
main.java code:
main.java code:
我会好心AP preciate任何帮助,您可以给我。
I would kindly appreciate any help you could give me.
推荐答案
正如在评论你的问题,看来你的服务器返回的XML而不是JSON。你可以只输出的结果很容易地证实了这一点
:
As pointed out in the comments to your question, it appears that your server is returning XML rather than JSON. You can easily confirm this by just outputting result
:
}catch(JSONException e){
Log.e("log_tag", "Error parsing data "+e.toString());
Log.e("log_tag", "Failed data was:\n" + result);
}
如果是XML,它几乎可以肯定一定是,那么您可能需要获取服务器输出的JSON或者您需要解析它送你的XML。
If it's XML, which it almost certainly must be, then you either need to get the server to output JSON or you need to parse the XML that it's sending you.
这篇关于错误分析数据org.json.JSONException:值小于,java.lang.String类型的XML无法转换为JSONArray的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!