0

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

Community
  • 1
  • 1
Groosha
  • 2,897
  • 2
  • 22
  • 38

1 Answers1

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
  • 1
    Sorry 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
  • 1
    if 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