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
Add a comment
|
1 Answer
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 ;)
3 Comments
Groosha
Thanks, but that's not the question. The question is about "how to be able to work with xml file with GET request?"
falcon
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 stackoverflow.com/a/9606629/1326308
falcon
if you still want to use xml read docs developer.android.com/training/basics/network-ops/xml.html