Francisco Peters
Francisco Peters

Reputation: 697

Android XmlPullParser get value between tags

I have something like this in XML:

<trkpt lat="-32.577000" lon="-71.443764">
            <ele>2.204529</ele>
            <time>2015-12-27T12:35:45Z</time>

I can get lat and lon with

XmlPullParser parser = factory.newPullParser(); parser.getAttributeValue(0); parser.getAttributeValue(1);

But how can I get the value stored between the "ele" tag?

Upvotes: 1

Views: 1243

Answers (1)

Blackbelt
Blackbelt

Reputation: 157467

you have to use getText() on the current element. From the documentation

Returns the text content of the current event as String.

Of course you have to move the parser to the correct element calling next (). From the documentation:

Get next parsing event

Upvotes: 2

Related Questions