PullParser's getText returning null

84 views Asked by At

I am using pull parser to extract data from a XML String and have the below code. Now when the tag has been found and it also contains data/text in it I don’t understand why getText() is always returning null?

//…<tagDate>9/7/2014 12:00:00 AM</tagDate>…

xpp.next();
tagName = xpp.getName();
String text=xpp.getText();  //text is null
    if (tagName.equals("tagDate"))
    {
        xmlList.add(xpp.getText()); 
    }

Please help

1

There are 1 answers

0
Rolf ツ On BEST ANSWER

getText() returns null because the currently selected XML entry (don't read tag or element) doesn't have any text. This is because the currently selected XML entry is of the type: opening tag.

What you should do is call next() so the XML parser selects the next XML entry which is of the type: text.

The XML entry after another next call will be of the type: closing tag.