Android XmlPullParser Create getPullParserFromClass( ClassLoader classLoader, String fileName, String encoding)

Here you can find the source of getPullParserFromClass( ClassLoader classLoader, String fileName, String encoding)

Description

get Pull Parser From Class

License

Apache License

Declaration

public static XmlPullParser getPullParserFromClass(
            ClassLoader classLoader, String fileName, String encoding)
            throws XmlPullParserException 

Method Source Code

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

import java.io.InputStream;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlPullParserFactory;

public class Main {
    public static XmlPullParser getPullParserFromClass(
            ClassLoader classLoader, String fileName, String encoding)
            throws XmlPullParserException {
        return getPullParser(classLoader.getResourceAsStream(fileName),
                encoding);//  w w w . j  av  a2s. co  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. getPullParserFromAssert(Context context, String fileName, String encoding)