我正在试图找出为什么我在一个非常简单的Android应用程序中得到一个未终止的实体引用错误我一直在努力。我想要做的是从互联网上获取一个包含不同部分的餐馆菜单的xml文件,然后显示菜单项列表。当我使用this教程提供的示例XML(并更改它正在查找的字段的名称)时,它按预期工作,但是当我使用我真正想要的菜单(删除了链接)时,它不起作用。
这是我为测试而编写的方法。我删除了所有内容但基本知识仍然存在问题:
public void parseXMLTest(XmlPullParser parser)throws XmlPullParserException, IOException {
Log.d("menu","About to Parse...");
int eventType = parser.getEventType();
while(eventType != XmlPullParser.END_DOCUMENT) {
switch(eventType) {
case XmlPullParser.START_DOCUMENT:
Log.d("menu","Stat Doc");
break;
case XmlPullParser.START_TAG:
Log.d("menu","Stat Tag");
break;
case XmlPullParser.END_TAG:
Log.d("menu","End Tag");
break;
}
eventType = parser.next();
}
Log.d("menu","End Doc");
}
这是我得到的错误:
10-22 16:25:07.028 5318-5318/com.example.jake.purduefood W/System.err﹕ org.xmlpull.v1.XmlPullParserException: unterminated entity ref (position:TEXT @1:1726 in java.io.InputStreamReader@41bc3bd0)
10-22 16:25:07.028 5318-5318/com.example.jake.purduefood W/System.err﹕ at org.kxml2.io.KXmlParser.readEntity(KXmlParser.java:1210)
10-22 16:25:07.028 5318-5318/com.example.jake.purduefood W/System.err﹕ at org.kxml2.io.KXmlParser.readValue(KXmlParser.java:1392)
10-22 16:25:07.028 5318-5318/com.example.jake.purduefood W/System.err﹕ at org.kxml2.io.KXmlParser.next(KXmlParser.java:390)
10-22 16:25:07.028 5318-5318/com.example.jake.purduefood W/System.err﹕ at org.kxml2.io.KXmlParser.next(KXmlParser.java:310)
10-22 16:25:07.028 5318-5318/com.example.jake.purduefood W/System.err﹕ at com.example.jake.purduefood.MainActivity.parseXML(MainActivity.java:131)
10-22 16:25:07.028 5318-5318/com.example.jake.purduefood W/System.err﹕ at com.example.jake.purduefood.MainActivity.onCreate(MainActivity.java:47)
10-22 16:25:07.028 5318-5318/com.example.jake.purduefood W/System.err﹕ at android.app.Activity.performCreate(Activity.java:5312)
10-22 16:25:07.028 5318-5318/com.example.jake.purduefood W/System.err﹕ at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1111)
10-22 16:25:07.028 5318-5318/com.example.jake.purduefood W/System.err﹕ at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2541)
10-22 16:25:07.028 5318-5318/com.example.jake.purduefood W/System.err﹕ at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2641)
10-22 16:25:07.028 5318-5318/com.example.jake.purduefood W/System.err﹕ at android.app.ActivityThread.access$800(ActivityThread.java:156)
10-22 16:25:07.028 5318-5318/com.example.jake.purduefood W/System.err﹕ at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1355)
10-22 16:25:07.028 5318-5318/com.example.jake.purduefood W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:102)
10-22 16:25:07.028 5318-5318/com.example.jake.purduefood W/System.err﹕ at android.os.Looper.loop(Looper.java:157)
10-22 16:25:07.028 5318-5318/com.example.jake.purduefood W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5867)
10-22 16:25:07.028 5318-5318/com.example.jake.purduefood W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method)
10-22 16:25:07.028 5318-5318/com.example.jake.purduefood W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:515)
10-22 16:25:07.028 5318-5318/com.example.jake.purduefood W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:858)
10-22 16:25:07.028 5318-5318/com.example.jake.purduefood W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:674)
10-22 16:25:07.028 5318-5318/com.example.jake.purduefood W/System.err﹕ at dalvik.system.NativeStart.main(Native Method)
另外,这是我在StackOverflow上的第一篇文章,所以如果我没有正确地询问或需要更改某些内容,请告诉我们!我真的很感激任何建议!