title: getting a java.Lang.NULLPOINTEREXCEPTION at line "ParseDocument(doc)" and "Element docEle = dom.getDocumentElement();"
body: <p>here i am just trying to parse an xml file and store the contents in an array lists, but everytime its giving java.Lang.NullPointerException at two points, pls help in debugging this...</p>
  
  <pre><code>public class XML_PARSER extends Activity {
  
  String TAG= "XML_PARSER";
  List optionList = new ArrayList(); 
  Document dom;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.parser);
  
  
  
      Document doc=parseXmlFile();
  </code></pre>
  
  <p>at this line it is giving a java null pointer exception</p>
  
  <pre><code>    ParseDocument(doc); 
  
      //printData();
  
  
  }
  private Document parseXmlFile(){
      DocumentBuilderFactory dbf= DocumentBuilderFactory.newInstance();
  
      try {
          DocumentBuilder db = dbf.newDocumentBuilder();
          dom=db.parse("R.raw.options.xml");
  
      }
  
      catch(ParserConfigurationException pce){
          pce.printStackTrace();
      }
      catch(SAXException se){
          se.printStackTrace();
      }
      catch(IOException ioe){
          ioe.printStackTrace();
      }
      return dom;
  
  }
  
  
  private void ParseDocument(Document dom){
  </code></pre>
  
  <p>at this lineits giving the same error</p>
  
  <pre><code>    Element docEle = dom.getDocumentElement();
      Node node;
  
      NodeList n1= docEle.getElementsByTagName("Option");
      if(n1!=null &amp;&amp; n1.getLength()&gt;0){
          for(int i=0;i&lt;n1.getLength();i++){
              node=n1.item(i);
  
              Element e1=(Element)n1.item(i);
  
              Option e = getOption(e1,node);
  
              optionList.add(e);
  
              }
  
          }
      }
  </code></pre>
  
  <p>here is the log cat for the same</p>
  
  <pre><code>07-20 12:21:48.391: E/AndroidRuntime(836): Caused by: java.lang.NullPointerException
  07-20 12:21:48.391: E/AndroidRuntime(836):  at com.example.xml_parser.XML_PARSER.ParseDocument(XML_PARSER.java:67)
  
  07-20 12:21:48.391: E/AndroidRuntime(836):  at com.example.xml_parser.XML_PARSER.onCreate(XML_PARSER.java:38)
  
  07-20 12:21:48.391: E/AndroidRuntime(836):  at android.app.Activity.performCreate(Activity.java:5008)
  
  07-20 12:21:48.391: E/AndroidRuntime(836):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
  
  07-20 12:21:48.391: E/AndroidRuntime(836):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
  </code></pre>