Reputation: 7567
I'm using XmlResourceParser
to extract values from elements. I used msgBody= xmlResourceParser.nextText();
which returns value from both Message element i.e i'm glad that you came to see me
and Sorry wrong number
. I want to get only one from the top, how can i get that? My xml file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<Messages>
<Contact Name="Tomas" Number="079399877339">
<Message Date="30 Jan 2012" Time="23:36">i'm happy that you go to see her</Message>
<Message Date="31 Jan 2012" Time="11:34">this is a sample message</Message>
</Contact>
</Messages>
.getText()
throws NullPointerException.
Upvotes: 1
Views: 453
Reputation: 19796
Your implementation is wrong. To fix it:
List<Message>
) Upvotes: 1