Android XML Document Load loadFile(Context context, String fileName)

Here you can find the source of loadFile(Context context, String fileName)

Description

load File

Declaration

public static Document loadFile(Context context, String fileName) 

Method Source Code

//package com.java2s;
import java.io.File;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import android.content.Context;

public class Main {
    public static Document loadFile(Context context, String fileName) {
        File cacheDir = context.getCacheDir();
        File file = new File(cacheDir, fileName);

        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db;/*from   www. j  a  v  a2 s .co m*/
        Document document = null;

        try {
            db = dbf.newDocumentBuilder();

            document = db.parse(file);
            document.getDocumentElement().normalize();
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

        return document;
    }
}

Related

  1. getDocument(String strxml)
  2. getDocument(String strxml)
  3. loadXMLFromString(String xml)
  4. load(String filename)
  5. loadData(String xmlData)