Garmaine Staff asked 2 years ago

I am trying to parse a XML file in my android app and tried following the Android Developers examples on the site. However, even when all of the tags within the 'start' tags have been processed, the program continues in an infinite loop, never gets out of 'while ( != XmlPullParser.END_TAG)' loop even though my XML file starts and ends with <data> and </data> tags. What am I doing wrong?

 public List parse(InputStream in) throws XmlPullParserException, IOException { /* Function that takes Assay file as input stream */
        try {
            XmlPullParser parser = Xml.newPullParser(); /* Create new parser  */
            parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, true); /*  */
            parser.setInput(in, null);
            return readFeed(parser); /* extracts and processes the data */
        } finally {
 private List readFeed(XmlPullParser parser) throws XmlPullParserException, IOException {
        List girlNameList = new ArrayList();
        List boyNameList = new ArrayList();
        parser.require(XmlPullParser.START_TAG, ns, "data"); 

        while ( != XmlPullParser.END_TAG) { 
            if (parser.getEventType() != XmlPullParser.END_TAG) {
            String currentTag = parser.getName();         
            if(currentTag.equals("emily")) {            
            } else if(currentTag.equals("robert") {
            } else {
        return namesList;
    <emily type="short" msg="======something==========">  </emily>
    <emily type="tall" msg="======another message==========">  </emily>

    <robert type="short" > </robert>

    <emily type="tall" > </emily>

    <robert type="tall" msg="use this later" > </robert>
    <tester type="n/a" msg="should be skipped" > </tester>