关于Xml Parser Null Point Exception

时间:2014-03-09 06:58:34

标签: android xml-parsing

我使用这个教程http://www.androidhive.info/2012/02/android-custom-listview-with-image-and-text/并制作了一个应用程序。当我运行时,我在XML Parser中得到Null Point异常错误。我附加了log cat

03-09 12:18:38.126: E/AndroidRuntime(32684): FATAL EXCEPTION: main
03-09 12:18:38.126: E/AndroidRuntime(32684): Process: com.themebowlapps.themebowl, PID: 32684
03-09 12:18:38.126: E/AndroidRuntime(32684): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.themebowlapps.themebowl/com.themebowlapps.themebowl.ChannelListView}: java.lang.NullPointerException
03-09 12:18:38.126: E/AndroidRuntime(32684):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2282)
03-09 12:18:38.126: E/AndroidRuntime(32684):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2340)
03-09 12:18:38.126: E/AndroidRuntime(32684):    at android.app.ActivityThread.access$800(ActivityThread.java:157)
03-09 12:18:38.126: E/AndroidRuntime(32684):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1247)
03-09 12:18:38.126: E/AndroidRuntime(32684):    at android.os.Handler.dispatchMessage(Handler.java:102)
03-09 12:18:38.126: E/AndroidRuntime(32684):    at android.os.Looper.loop(Looper.java:157)
03-09 12:18:38.126: E/AndroidRuntime(32684):    at android.app.ActivityThread.main(ActivityThread.java:5293)
03-09 12:18:38.126: E/AndroidRuntime(32684):    at java.lang.reflect.Method.invokeNative(Native Method)
03-09 12:18:38.126: E/AndroidRuntime(32684):    at java.lang.reflect.Method.invoke(Method.java:515)
03-09 12:18:38.126: E/AndroidRuntime(32684):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1259)
03-09 12:18:38.126: E/AndroidRuntime(32684):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
03-09 12:18:38.126: E/AndroidRuntime(32684):    at dalvik.system.NativeStart.main(Native Method)
03-09 12:18:38.126: E/AndroidRuntime(32684): Caused by: java.lang.NullPointerException
03-09 12:18:38.126: E/AndroidRuntime(32684):    at java.io.StringReader.<init>(StringReader.java:47)
03-09 12:18:38.126: E/AndroidRuntime(32684):    at com.themebowlapps.themebowl.XMLParser.getDomElement(XMLParser.java:73)
03-09 12:18:38.126: E/AndroidRuntime(32684):    at com.themebowlapps.themebowl.ChannelListView.onCreate(ChannelListView.java:58)
03-09 12:18:38.126: E/AndroidRuntime(32684):    at android.app.Activity.performCreate(Activity.java:5389)
03-09 12:18:38.126: E/AndroidRuntime(32684):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
03-09 12:18:38.126: E/AndroidRuntime(32684):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2246)
03-09 12:18:38.126: E/AndroidRuntime(32684):    ... 11 more

根据此代码 XMLParser.java中的第73行是

InputSource is = new InputSource();
           is.setCharacterStream(new StringReader(xml));
            doc = db.parse(is); 

和第58行是

String xml = parser.getXmlFromUrl(URL); // getting XML from URL
    Document doc = parser.getDomElement(xml); // getting DOM element

我无法理解错误是什么。任何人都可以帮我解决它吗?

0 个答案:

没有答案