org.xmlpull.v1.XmlPullParserException:读取没有标签打开的结束标记键

时间:2015-11-27 15:30:27

标签: android android-xml android-pullparser

org.xmlpull.v1.XmlPullParserException:读取没有标签打开的结束标记键(位置:在java.io.InputStreamReader@83d457b中为END_TAG @ 1:7)

Android 6.0(API 23) xml有什么问题?或者还有什么可能是这种例外的原因? 如果我没有弄错,那么@ 1:7是该行中的第1行和符号7(或者可能是反向第7行)。但我在这个xml中找不到什么错误。

非常感谢!

<plist version="1.0">
<dict>
<key>Golfs</key>
<array>
<dict>
<key>GLF_COD</key>
<string>0661</string>
<key>GLF_LIB</key>
<string>AA SAINT OMER GOLF CLUB</string>
<key>GLF_ADR_1</key>
<string>Chemin des Bois</string>
<key>GLF_ADR_2</key>
<string/>
<key>GLF_CPO</key>
<string>62380</string>
<key>GLF_DIS</key>
<string>ACQUIN WESTBECOURT</string>

    public class ClubCategoriesInflater extends XMLInflater<List<ClubCategory>> {

    @Override
    protected void onInflate(List<ClubCategory> clubCategories, InputStream stream) {

        int START_NUMBER = 2;
        int arrayTagNumber = 0;
        ClubCategory clubCategory = null;
        XmlPullParser parser = getParser();

        if (parser!=null){
            String startTag = null;
            String lastKey = null;
            try {
                int eventType = parser.getEventType();
                while (eventType != XmlPullParser.END_DOCUMENT) {
                    if(eventType == XmlPullParser.START_TAG) {
                        startTag = parser.getName();
                        if ("array".equals(startTag)){
                            arrayTagNumber++;
                        }
                        if ("dict".equals(startTag)){
                            clubCategory = new ClubCategory();
                        }
                    } else if(eventType == XmlPullParser.END_TAG) {
                        startTag = null;
                        if (arrayTagNumber==START_NUMBER){
                            if ("dict".equals((parser.getName()))){
                                clubCategories.add(clubCategory);
                            }
                            if ("array".equals((parser.getName()))){
                                return;
                            }
                        }
                    } else if(arrayTagNumber==START_NUMBER && startTag!=null && eventType == XmlPullParser.TEXT) {
                        if (key.equals(startTag)){
                            lastKey = parser.getText();
                        }else if (string.equals(startTag)){
                            if ("id".equals(lastKey)){
                                clubCategory.id = Integer.valueOf(parser.getText());
                            }
                            else if ("name".equals(lastKey)){
                                clubCategory.name = parser.getText();
                            }
                        }
                    }
                    eventType = parser.next();
                }
            } catch (XmlPullParserException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}

enter image description here

enter image description here

enter image description here

链接到该xml https://esplic-ws1.ffgolf.org/iphone/get_golfs_plist.php?av=1.2&sv=6.0&sn=Android%20OS&su=c19f0b9cc0a3c911&sl=en&sm=Nexus+7

0 个答案:

没有答案