I have a problem with parsing XML file on android.
My examples.xml file look like this:
<categories>
<example>something</example>
</categories>
And my Java code:
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder db = dbf.newDocumentBuilder();
Document doc = db.parse(getResources().openRawResource(R.xml.examples));
doc.getDocumentElement().normalize(); //here it throws NullPointerException
It throws a NullPointerException when I try to normalize().
I am inspired by this simple tutorial http://sanjaal.com/java/tag/getdocumentelementnormalize/
Can anyone tell me what I'm doing wrong? Thanks