sorry for my bad English.
I've managed how to get authorization token from this question
And now I can't get how to work with XML.
The documentation says (translating):
get contents of /me/ resource:
https://api-yaru.yandex.ru/me/?oauth_token=111111111111111111
The answer will be in XML format
Please, explain, how can I get this XML file to parse it?
Do I need to use AsyncTask?
The "dirty" code is here: http://pastebin.com/NjTiUpC5
Asked
Active
Viewed 72 times
0
1 Answers
1
you need to simply append '&format=json' into your url to get response in json format
https://api-yaru.yandex.ru/me/?oauth_token=111111111111111111&format=json
in your case
HttpEntity entity = resp.getEntity();
String jsonStr = EntityUtils.toString(entity);
JSONObject jsonObj = new JSONObject(jsonStr);
and for get xml string
String xml = EntityUtils.toString(resp.getEntity());
if you want to simply print it
and do what ever you want. good luck ;)

falcon
- 372
- 3
- 19
-
Thanks, but that's not the question. The question is about "how to be able to work with xml file with GET request?" – Groosha Jul 31 '13 at 22:25
-
1Sorry but part of your original message was "Please, explain, how can I get this XML file (or JSON, what's better?) to parse it?". If you still think about json see this link http://stackoverflow.com/a/9606629/1326308 – falcon Jul 31 '13 at 22:49
-
1if you still want to use xml read docs http://developer.android.com/training/basics/network-ops/xml.html – falcon Jul 31 '13 at 22:56