Search in sources :

Example 41 with XmlPullParserFactory

use of org.xmlpull.v1.XmlPullParserFactory in project Java by bottleleung.

the class XmlManager method getXmlParser.

/**
 * ��ȡXML������
 * @param fileName	��Ҫ������xml�ļ�·�����ļ�����������׺�������׺ͳһ��plist,�б�Ҫ���޸ģ�
 * @param encode	�ַ�������
 * @return
 */
public static XmlPullParser getXmlParser(String fileName, String encode) {
    try {
        // ��ô��� xml �ļ��� XmlResourceParser ����
        // XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance(System.getProperty(XmlPullParserFactory.PROPERTY_NAME), Thread.currentThread().getContextClassLoader().getClass());
        factory.setNamespaceAware(true);
        XmlPullParser xml = factory.newPullParser();
        xml.setInput(new FileInputStream(fileName + ".plist"), encode);
        return xml;
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
Also used : XmlPullParserFactory(org.xmlpull.v1.XmlPullParserFactory) XmlPullParser(org.xmlpull.v1.XmlPullParser) FileInputStream(java.io.FileInputStream)

Aggregations

XmlPullParserFactory (org.xmlpull.v1.XmlPullParserFactory)41 XmlPullParser (org.xmlpull.v1.XmlPullParser)29 IOException (java.io.IOException)15 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)15 InputStream (java.io.InputStream)11 StringReader (java.io.StringReader)7 InputStreamReader (java.io.InputStreamReader)6 XmlSerializer (org.xmlpull.v1.XmlSerializer)5 XmlResourceParser (android.content.res.XmlResourceParser)4 IOException2 (hudson.util.IOException2)4 FileInputStream (java.io.FileInputStream)4 File (java.io.File)3 HashMap (java.util.HashMap)3 Reader (java.io.Reader)2 Iterator (java.util.Iterator)2 ParseConfigurationFileException (org.litepal.exceptions.ParseConfigurationFileException)2 PackageManager (android.content.pm.PackageManager)1 Resources (android.content.res.Resources)1 NonNull (android.support.annotation.NonNull)1 VisibleForTesting (android.support.annotation.VisibleForTesting)1