getting a java.Lang.NULLPOINTEREXCEPTION at line "ParseDocument(doc)" and "Element docEle = dom.getDocumentElement();"
===

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...



    package com.example.xml_parser;

    import java.io.IOException;
    import java.util.ArrayList;
    import java.util.List;

    import javax.xml.parsers.DocumentBuilder;
    import javax.xml.parsers.DocumentBuilderFactory;
    import javax.xml.parsers.ParserConfigurationException;

    import org.w3c.dom.Document;
    import org.w3c.dom.Element;
    import org.w3c.dom.Node;
    import org.w3c.dom.NodeList;
    import org.xml.sax.SAXException;

    import android.os.Bundle;
    import android.app.Activity;
    import android.view.Menu;
    import android.view.MenuItem;
    import android.support.v4.app.NavUtils;

    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();

at this line it is giving a java null pointer exception     
        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){

at this lin eits giving the same error
    	Element docEle = dom.getDocumentElement();
    	Node node;
    	
    	NodeList n1= docEle.getElementsByTagName("Option");
    	if(n1!=null && n1.getLength()>0){
    		for(int i=0;i<n1.getLength();i++){
    			node=n1.item(i);
    			
    			Element e1=(Element)n1.item(i);
    			
    			Option e = getOption(e1,node);
    			
    			optionList.add(e);
    			
    			}
    		
    		}
    	}
    
    private Option getOption(Element el,Node parent){
    	String name= getTextValue(el,"Name");
    	String type = el.getAttribute("type");
    	
    	if(type.equals("action")){
    		String function = getTextValue(el,"Function");
    	}
    	Option op = new Option(name,type);
    	fillSubOptions(op, el, parent);
    	return op;
    	
    	
    }
    
    private String getTextValue(Element ele, String tagName){
    	String textVal=null;
    	NodeList n1 = ele.getElementsByTagName(tagName);
    	
    	if(n1!=null && n1.getLength()>0){
    		Element el= (Element)n1.item(0);
    		textVal =el.getFirstChild().getNodeValue();
    		
    	}
    	return textVal;
    }
    
    
    private void fillSubOptions(Option op, Element el, Node parent){
    	Element ele;
    	Node node;
    	String name = null;
    	NodeList n1 = el.getElementsByTagName("Option");
    	
    	if(n1!=null && n1.getLength()>0){
    		for(int i=0;i<n1.getLength();i++){
    			ele = (Element)n1.item(i);
    			node= n1.item(i);
    			if((node.getParentNode()).equals(parent)){
    				name= getTextValue(ele, "Name");
    				op.setSubOptions(name);
    			}
    		}
    	}
    	
    }
    
    
    
    
    
    
    
    

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        getMenuInflater().inflate(R.menu.parser, menu);
        return true;
    }
    public class Option {

    	
		String name;
    	String type;
    	String parent;
    	ArrayList<String> subOptions;
    	Option(String name,String type)
    	{
    		setName(name);
    		setType(type);
    		subOptions = new ArrayList<String>();
    		parent = null;
    	}
    	public void setName(String name) {
    		this.name = name;
    	}
    	
    	public void setType(String type) {
    		this.type = type;
    	}
    	public void setSubOptions(String subOption) {
    		(this.subOptions).add(subOption);
    	}
    	
    }

    
    }
