K
K
Kurban Mammaev2015-05-11 21:11:44
Java
Kurban Mammaev, 2015-05-11 21:11:44

How to read text from xml file in android application?

Hello. There is an xml file on the server that looks like this:

<response>
<date_act>2015-05-05</date_act>
<symbol>U</symbol>
<rate>2517</rate>
<size>1</size>
</response>

I need to read this file by reference and pull out the value of the rate (just read it as one line, and then take the right one through substring). How to read xml file as text in android application?
Please answer in detail. Thank you in advance.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
O
Oleg Gamega, 2015-05-11
@Axe98

if only this then get a request for xxx/file_name.xml and in the response a line will come in which will be the contents of the xml file.

O
Olzhas Ilyubayev, 2015-05-11
@ilyubayev

As an option.
Use Jsoup java library .
Jsoup is an HTML parser, but I think there will be no problems with such an XML file.
In addition, this library can also generate HTTP requests. On off. There are plenty of examples of Get requests and file navigation in the Cookbook section of the site.

B
boomwest, 2015-05-12
@boomwest

Upload url to Asynctask. Pass the result to XmlPullParser.
You need a book. Brian Hardy, Bill Phillips - Android Programming. from page 429.
Better yet, from the first to the last.

A
Afanasiy Nikitin, 2015-05-14
@afanasiy_nikitin

umm.. there is no XPath in android?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question