0

a を解析しOnline XML Fileて、アイテム (サブアイテム) を a に書き込もうとしていListviewます。しかし、私はjava.lang.NullPointerException. エラーメッセージがあまり役に立たないことはわかっていますが、この問題に座って、すでに2時間決定されています...

私のコード:

        try {

        URL url;
        url = new URL("http://domain.tld/file.xml");

        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document doc = db.parse(new InputSource(url.openStream()));
        doc.getDocumentElement().normalize();
        NodeList nodeList = doc.getElementsByTagName("item");

        for (int i = 0; i < nodeList.getLength(); i++) {
            Node node = nodeList.item(i);
            Element fstElmnt = (Element) node;
            NodeList nameList = fstElmnt.getElementsByTagName("subitemname");
            Element nameElement = (Element) nameList.item(0);
            nameList = nameElement.getChildNodes();
            valueList.add(nameList.item(0).getNodeValue());
            NodeList websiteList = fstElmnt.getElementsByTagName("subitem2");
            Element websiteElement = (Element) websiteList.item(0);
            websiteList = websiteElement.getChildNodes();
        }
        ListAdapter adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_list_item_1, valueList);
        final ListView lv = (ListView)findViewById(R.id.listview);
        lv.setAdapter(adapter);
    } catch (Exception e) {
        System.out.println("XML Pasing Excpetion = " + e);
    }

スタックトレース:

10-07 23:44:00.460  13715-13715/com.app.name W/System.err﹕ java.lang.NullPointerException
10-07 23:44:00.470  13715-13715/com.app.name W/System.err﹕ at com.app.name.add_series.onCreate(add_series.java:82)
10-07 23:44:00.470  13715-13715/com.app.name W/System.err﹕ at android.app.Activity.performCreate(Activity.java:5133)
10-07 23:44:00.470  13715-13715/com.app.name W/System.err﹕ at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
10-07 23:44:00.470  13715-13715/com.app.name W/System.err﹕ at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2293)
10-07 23:44:00.470  13715-13715/com.app.name W/System.err﹕ at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2389)
10-07 23:44:00.470  13715-13715/com.app.name W/System.err﹕ at android.app.ActivityThread.access$600(ActivityThread.java:153)
10-07 23:44:00.470  13715-13715/com.app.name W/System.err﹕ at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1269)
10-07 23:44:00.470  13715-13715/com.app.name W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:99)
10-07 23:44:00.470  13715-13715/com.app.name W/System.err﹕ at android.os.Looper.loop(Looper.java:137)
10-07 23:44:00.470  13715-13715/com.app.name W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5289)
10-07 23:44:00.470  13715-13715/com.app.name W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method)
10-07 23:44:00.470  13715-13715/com.app.name W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:525)
10-07 23:44:00.470  13715-13715/com.app.name W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:739)
10-07 23:44:00.470  13715-13715/com.app.name W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:555)
10-07 23:44:00.470  13715-13715/com.app.name W/System.err﹕ at dalvik.system.NativeStart.main(Native Method)
10-07 23:44:00.550  13715-13715/com.app.name W/IInputConnectionWrapper﹕ finishComposingText on inactive InputConnection
10-07 23:44:00.550  13715-13715/com.app.name W/IInputConnectionWrapper﹕ finishComposingText on inactive InputConnection

エラー:I/System.out﹕ XML Pasing Excpetion = java.lang.NullPointerException

4

2 に答える 2