Android XmlPullParser Create getPullParserFromAssert(Context context, String fileName, String encoding)

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

Description

get Pull Parser From Assert

License

Apache License

Declaration

public static XmlPullParser getPullParserFromAssert(Context context,
            String fileName, String encoding)
            throws XmlPullParserException, IOException 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.io.IOException;
import java.io.InputStream;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;
import android.content.Context;

public class Main {
    public static XmlPullParser getPullParserFromAssert(Context context,
            String fileName, String encoding)
            throws XmlPullParserException, IOException {
        return getPullParser(
                context.getAssets().open(fileName, Context.MODE_PRIVATE),
                encoding);//w ww .j  a  v  a  2  s .  c o m
    }

    public static XmlPullParser getPullParser(InputStream in,
            String encoding) throws XmlPullParserException {
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        factory.setNamespaceAware(true);
        XmlPullParser pullParser = null;
        pullParser = factory.newPullParser();
        pullParser.setInput(in, encoding);
        return pullParser;
    }
}

Related

  1. getXmlPullParser(String xml)
  2. makeInstanceFromUrl(Context context, URL url)
  3. makeInstanceFromUrl(Context context, URL url, String filename)
  4. getPullParserFromClass( ClassLoader classLoader, String fileName, String encoding)