title: When i try to parse XML. (java.lang.NullPointerException)
body: <p>I try to parse a <code>Online XML File</code> and to write the items (subitem) to a <code>Listview</code>. But i get a <code>java.lang.NullPointerException</code>. I know the error message is not really helpful but i'm sitting on this problem now already determined two hours ...</p>
  
  <p>My Code:</p>
  
  <pre><code>        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 &lt; 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&lt;String&gt;(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);
      }
  </code></pre>
  
  <p>Stacktrace:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>Error: <code>I/System.out﹕ XML Pasing Excpetion = java.lang.NullPointerException</code></p>