忽略XmlPullParser android中的内部标记

时间:2015-11-24 14:17:23

标签: android html tags xmlpullparser

<p>The Dog sports Sports like <em> agility </em>, flyball, obedience, rally obedience, musical freestyle and tracking can give you and your dog a whole new world of fun exercise and competition to explore. <strong>Activities</strong> for specific breed groups include herding, lure coursing, hunt tests and go-to-ground trials. For more information on these and other sports, </p>

我想获取段落标记内的所有文本(如下所示),但它会在(em标记)&#34; parser.nextText(); &#34;
任何人都知道如何做到这一点,提前谢谢。

狗体育运动如敏捷,飞球,服从,集会服从,音乐自由泳和跟踪可以为您和您的狗提供一个全新的有趣运动和竞赛探索世界。特定品种群体的活动包括放牧,诱饵,狩猎测试和实地试验。有关这些和其他运动的更多信息,

这是代码

int eventType = parser.getEventType();
while (eventType != XmlPullParser.END_DOCUMENT){
            String name = null;

            switch (eventType){
                case XmlPullParser.START_DOCUMENT:
                    Drugs = new ArrayList();
                    break;
                case XmlPullParser.START_TAG:
                    name = parser.getName();
                    if (name.equals("p"))
                    {

                        String s=parser.nextText();


                    }
                break;
                case XmlPullParser.END_TAG:

            }
            eventType = parser.next();
        }

这是log

11-24 19:22:01.357:W / System.err(29010):org.xmlpull.v1.XmlPullParserException:END_TAG expected(position:START_TAG @ 47:333 in java.io.InputStreamReader@4b9110e) 11-24 19:22:01.357:W / System.err(29010):at org.kxml2.io.KXmlParser.nextText(KXmlParser.java:2086) 11-24 19:22:01.357:W / System.err(29010):at com.magsol.drugdictionary.Detail.parseXML(Detail.java:227) 11-24 19:22:01.357:W / System.err(29010):at com.magsol.drugdictionary.Detail.onCreate(Detail.java:116) 11-24 19:22:01.357:W / System.err(29010):在android.app.Activity.performCreate(Activity.java:6020) 11-24 19:22:01.357:W / System.err(29010):at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105) 11-24 19:22:01.357:W / System.err(29010):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2259) 11-24 19:22:01.357:W / System.err(29010):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2368) 11-24 19:22:01.357:W / System.err(29010):在android.app.ActivityThread.access $ 800(ActivityThread.java:149) 11-24 19:22:01.357:W / System.err(29010):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1284) 11-24 19:22:01.357:W / System.err(29010):在android.os.Handler.dispatchMessage(Handler.java:102) 11-24 19:22:01.357:W / System.err(29010):在android.os.Looper.loop(Looper.java:135) 11-24 19:22:01.357:W / System.err(29010):在android.app.ActivityThread.main(ActivityThread.java:5299) 11-24 19:22:01.357:W / System.err(29010):at java.lang.reflect.Method.invoke(Native Method) 11-24 19:22:01.357:W / System.err(29010):at java.lang.reflect.Method.invoke(Method.java:372) 11-24 19:22:01.357:W / System.err(29010):at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:908) 11-24 19:22:01.357:W / System.err(29010):at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:703)

0 个答案:

没有答案