Android HTTPPost 正文解析
我在解析返回到 Android 应用程序的一些 XML 数据时遇到了很大的挑战。 数据以 XML 形式发送,但将其打印在我的移动屏幕上,结果如下:
{"sessid":"5eed0b52c6953b52e262b559b5557be4","session_name":"SESS6cbf091341a26e4687fa7850b465755a,"user":{"uid":"15","name":"guest","pass":"084e0343a0486ff05530df6c705c8bb4","mail":"[email protected]", "mode":"0","sort":"0","threshold":"0","theme":"","signature":"","signature_format":"0","created":"1306008217","access":"1306094503","login":"1306134979","status":"1","timezone":"3600","language":"","picture":"","init":"[email protected]","data":a:1:{s:13:\"form_build_id\";s:37:\"form-49ea7a4ef10a8a2b31478696f17e8dee\";","form_build_id":"form-49ea7a4ef10a8a2b31478696f17e8dee","roles":{"2":"authenticated user","3":"guest"}}}
任何人都可以帮助新手并给我一些关于如何解析这种类型的输出和/或纯 XML 的想法吗?
I am having a really challenging time parsing some XML data returned to my Android app.
The data is sent as XML but printing it on my mobile screen, it comes out as the following:
{"sessid":"5eed0b52c6953b52e262b559b5557be4","session_name":"SESS6cbf091341a26e4687fa7850b465755a,"user":{"uid":"15","name":"guest","pass":"084e0343a0486ff05530df6c705c8bb4","mail":"[email protected]", "mode":"0","sort":"0","threshold":"0","theme":"","signature":"","signature_format":"0","created":"1306008217","access":"1306094503","login":"1306134979","status":"1","timezone":"3600","language":"","picture":"","init":"[email protected]","data":a:1:{s:13:\"form_build_id\";s:37:\"form-49ea7a4ef10a8a2b31478696f17e8dee\";","form_build_id":"form-49ea7a4ef10a8a2b31478696f17e8dee","roles":{"2":"authenticated user","3":"guest"}}}
Can anyone please help a newbie and give me some ideas on how to parse this type of output and/or plain XML?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这不是 XML,而是 JSON。您必须使用 JSON API 解析该字符串。
基本上,您通过将字符串输入 < 来创建一个
JSONObject
代码>JSONTokenizer。您现在可以按照 API 参考示例中的说明从JSONObject
查询值。This isn't XML but JSON. You have to parse that string using the JSON API.
Basically you create a
JSONObject
by feeding the string into aJSONTokenizer
. You can now query the values from theJSONObject
as described in the API reference example.您在这里看到的字符串是 JSON 格式。您可以使用以下库在 Andriod 中解析此内容:http://code.google.com/p /google-gson/
有关 json 的详细信息,请查看 http://json.org。
The String you're seeing here is in JSON format. You can parse this in Andriod using the following library : http://code.google.com/p/google-gson/
For more info on json, checkout http://json.org.