1

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?

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

1 Comment

You're right, I just needed to check the tag using something like "if("ele".equals(Parser.getName()) and then use getText. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.