Search code examples
androidxmlassets

How to read from assets folder into DOM xml parser?


Please help me with following problem. In my android assets folder I have xml file, called frames.xml I also have a class which parses this file like DOM.

DocumentBuilder db = dbf.newDocumentBuilder();
dom = db.parse(fileName);

So my question is how can I read that file from assets folder, by using this xml parser? Thank you on advance.


Solution

  • Try:

    DocumentBuilder db = dbf.newDocumentBuilder();
    dom = db.parse(context.getAssets().open(filename));