当前位置: 首页>>代码示例>>Java>>正文


Java XmlPullParserFactory.newInstance方法代码示例

本文整理汇总了Java中org.xmlpull.v1.XmlPullParserFactory.newInstance方法的典型用法代码示例。如果您正苦于以下问题:Java XmlPullParserFactory.newInstance方法的具体用法?Java XmlPullParserFactory.newInstance怎么用?Java XmlPullParserFactory.newInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.xmlpull.v1.XmlPullParserFactory的用法示例。


在下文中一共展示了XmlPullParserFactory.newInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: i

import org.xmlpull.v1.XmlPullParserFactory; //导入方法依赖的package包/类
private void i() {
    XmlPullParser newPullParser;
    InputStream open;
    try {
        XmlPullParserFactory newInstance = XmlPullParserFactory.newInstance();
        newInstance.setNamespaceAware(true);
        newPullParser = newInstance.newPullParser();
        open = this.b.getAssets().open("ShareSDK.xml");
    } catch (Throwable th) {
        Ln.e(th);
        return;
    }
    newPullParser.setInput(open, Constants.UTF_8);
    for (int eventType = newPullParser.getEventType(); eventType != 1; eventType = newPullParser.next()) {
        if (eventType == 2) {
            String name = newPullParser.getName();
            HashMap hashMap = new HashMap();
            int attributeCount = newPullParser.getAttributeCount();
            for (eventType = 0; eventType < attributeCount; eventType++) {
                hashMap.put(newPullParser.getAttributeName(eventType), newPullParser.getAttributeValue(eventType).trim());
            }
            this.c.put(name, hashMap);
        }
    }
    open.close();
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:27,代码来源:k.java

示例2: getApplicationName

import org.xmlpull.v1.XmlPullParserFactory; //导入方法依赖的package包/类
/**
 * get application name
 *
 * @param apkPath apkPath
 * @return String
 */
public static String getApplicationName(String apkPath) {
    if (apkPath == null || "".equals(apkPath)) {
        return null;
    }
    try {
        ZipFile zipFile = new ZipFile(new File(apkPath), ZipFile.OPEN_READ);
        ZipEntry manifestXmlEntry = zipFile.getEntry(ApkManifestReader.DEFAULT_XML);
        String manifestXML = ApkManifestReader.getManifestXMLFromAPK(zipFile, manifestXmlEntry);
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        factory.setNamespaceAware(true);
        XmlPullParser parser = factory.newPullParser();
        parser.setInput(new StringReader(manifestXML));
        String applicationName = parseApplicationNameByManifest(parser);
        return applicationName;
    } catch (Exception e1) {
    }
    return "";
}
 
开发者ID:LiangMaYong,项目名称:android-apkbox,代码行数:25,代码来源:ApkManifestParser.java

示例3: convertToJSONObject

import org.xmlpull.v1.XmlPullParserFactory; //导入方法依赖的package包/类
private
@Nullable
JSONObject convertToJSONObject() {
    try {
        Tag parentTag = new Tag("", "xml");

        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        factory.setNamespaceAware(false);   // tags with namespace are taken as-is ("namespace:tagname")
        XmlPullParser xpp = factory.newPullParser();

        setInput(xpp);

        int eventType = xpp.getEventType();
        while (eventType != XmlPullParser.START_DOCUMENT) {
            eventType = xpp.next();
        }
        readTags(parentTag, xpp);

        unsetInput();

        return convertTagToJson(parentTag, false);
    } catch (XmlPullParserException | IOException e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:smart-fun,项目名称:XmlToJson,代码行数:27,代码来源:XmlToJson.java

示例4: parseIndex

import org.xmlpull.v1.XmlPullParserFactory; //导入方法依赖的package包/类
public static ArrayList<ConferenceMeta> parseIndex() throws XmlPullParserException, IOException {

        conferences = new ArrayList<>();

        pullParserFactory = XmlPullParserFactory.newInstance();
        XmlPullParser parser = pullParserFactory.newPullParser();
        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);

        Log.d("Parse", "parse");
        URL url = new URL(INDEX_FILE_URL);
        HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
        InputStream inputStream = null;

        try {
            inputStream = new BufferedInputStream(urlConnection.getInputStream());
            parser.setInput(inputStream, null);
            readIndex(parser);
        } finally {
            urlConnection.disconnect();
            inputStream.close();
        }

        return conferences;
    }
 
开发者ID:BuildmLearn,项目名称:mConference-Framework,代码行数:25,代码来源:IndexParser.java

示例5: fetchGroups

import org.xmlpull.v1.XmlPullParserFactory; //导入方法依赖的package包/类
/**
     * Get a list of group
     * @param url group url
     * @return a group list
     */
    public static ArrayList<Group> fetchGroups(String url){

        ArrayList<Group> _groups = new ArrayList<>();
        try{
            String _xmlString = getUrl(url);
//            Log.i(TAG, "Get the items: " + _xmlString);


            /**Create a xmlPullParser*/
            XmlPullParserFactory _factory = XmlPullParserFactory.newInstance();
            XmlPullParser _xmlPullParser = _factory.newPullParser();
            _xmlPullParser.setInput(new StringReader(_xmlString));

            parseGroups(_groups, _xmlPullParser);                       /**Parser the xml String*/


        } catch (XmlPullParserException e){
            e.printStackTrace();
        } catch (IOException e2) {
            // TODO: handle exception
        }

        return _groups;
    }
 
开发者ID:TwentySevenC,项目名称:Flickr-Photos,代码行数:30,代码来源:FlickrUtils.java

示例6: fetchPeople

import org.xmlpull.v1.XmlPullParserFactory; //导入方法依赖的package包/类
/**
     * A method to get a people
     * @param url url
     * @return a people
     */
    public static People fetchPeople(String url){
        People _people = new People();

        try{
            String _xmlString = getUrl(url);
//            Log.i(TAG, "Get the items: " + _xmlString);


            /**Create a xmlPullParser*/
            XmlPullParserFactory _factory = XmlPullParserFactory.newInstance();
            XmlPullParser _xmlPullParser = _factory.newPullParser();
            _xmlPullParser.setInput(new StringReader(_xmlString));

            parsePeople(_people, _xmlPullParser);                       /**Parser the xml String*/


        } catch (XmlPullParserException e){
            e.printStackTrace();
        } catch (IOException e2) {
            // TODO: handle exception
        }

        return _people;
    }
 
开发者ID:TwentySevenC,项目名称:Flickr-Photos,代码行数:30,代码来源:FlickrUtils.java

示例7: parseXMLResponse

import org.xmlpull.v1.XmlPullParserFactory; //导入方法依赖的package包/类
/**
 * Parse is as response of Share API
 * @param is
 * @return List of ShareRemoteFiles
 * @throws XmlPullParserException
 * @throws IOException
 */
public ArrayList<OCShare> parseXMLResponse(InputStream is) throws XmlPullParserException, IOException {

	try {
		// XMLPullParser
		XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
		factory.setNamespaceAware(true);

		XmlPullParser parser = Xml.newPullParser();
		parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
		parser.setInput(is, null);
		parser.nextTag();
		return readOCS(parser);

	} finally {
		is.close();
	}
}
 
开发者ID:PicFrame,项目名称:picframe,代码行数:25,代码来源:ShareXMLParser.java

示例8: toXml

import org.xmlpull.v1.XmlPullParserFactory; //导入方法依赖的package包/类
/**
 * To XML.
 *
 * @param outputStream
 *            the output stream.
 * @throws Exception
 *             a generic exception.
 */
public void toXml(OutputStream outputStream) throws Exception {
    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    XmlSerializer xs = factory.newSerializer();
    xs
            .setProperty(
                    "http://xmlpull.org/v1/doc/properties.html#serializer-indentation",
                    "  ");

    xs.setOutput(outputStream, "UTF-8");

    // first write XML declaration
    xs.startDocument("UTF-8", null);
    // add some empty lines before first start tag
    xs.ignorableWhitespace("\n");

    toXml(xs);

    xs.endDocument();
}
 
开发者ID:dvorka,项目名称:mindraider,代码行数:28,代码来源:Resource.java

示例9: fetchPhotos

import org.xmlpull.v1.XmlPullParserFactory; //导入方法依赖的package包/类
/**
     * Get a list of photo item
     * @param url photo item
     * @return a photo list
     */
    public static ArrayList<Photo> fetchPhotos(String url){
        Log.d(TAG, "fetchPhotos");
        ArrayList<Photo> _photos = new ArrayList<>();
        try{
            String _xmlString = getUrl(url);
//            Log.i(TAG, "Get the items: " + _xmlString);


            /**Create a xmlPullParser*/
            XmlPullParserFactory _factory = XmlPullParserFactory.newInstance();
            XmlPullParser _xmlPullParser = _factory.newPullParser();
            _xmlPullParser.setInput(new StringReader(_xmlString));

            parsePhotos(_photos, _xmlPullParser);                       /**Parser the xml String*/


        } catch (XmlPullParserException e){
            e.printStackTrace();
        } catch (IOException e2) {
            // TODO: handle exception
        }

        return _photos;
    }
 
开发者ID:TwentySevenC,项目名称:Flickr-Photos,代码行数:30,代码来源:FlickrUtils.java

示例10: setXmlPullParser

import org.xmlpull.v1.XmlPullParserFactory; //导入方法依赖的package包/类
public boolean setXmlPullParser(boolean mLookForXml) throws XmlPullParserException, IOException{
	if (!mLookForXml) {
		mXpp = mContext.getResources().getXml(R.xml.awesomeguy);
	}
	else {
		
	   XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
	   factory.setNamespaceAware(true);
	   mXpp = factory.newPullParser(); 	
	   File sdcard = Environment.getExternalStorageDirectory();
	   //Log.e("XML", sdcard.getAbsolutePath());
	   int BUFFER_SIZE = 8192;

	   
	   File mFileInput = new File(sdcard, SDCARD_FILE);
	   
	   FileReader mReader = new FileReader(mFileInput);
	   
	   BufferedReader in = new BufferedReader(mReader,BUFFER_SIZE);

	   mXpp.setInput(in);
		   
	}
	return true;
}
 
开发者ID:radiodee1,项目名称:awesomeguy,代码行数:26,代码来源:InitBackground.java

示例11: parseSettings

import org.xmlpull.v1.XmlPullParserFactory; //导入方法依赖的package包/类
@VisibleForTesting
static Imported parseSettings(InputStream inputStream, boolean globalSettings, List<String> accountUuids,
        boolean overview) throws SettingsImportExportException {

    if (!overview && accountUuids == null) {
        throw new IllegalArgumentException("Argument 'accountUuids' must not be null.");
    }

    try {
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        //factory.setNamespaceAware(true);
        XmlPullParser xpp = factory.newPullParser();

        InputStreamReader reader = new InputStreamReader(inputStream);
        xpp.setInput(reader);

        Imported imported = null;
        int eventType = xpp.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_TAG) {
                if (SettingsExporter.ROOT_ELEMENT.equals(xpp.getName())) {
                    imported = parseRoot(xpp, globalSettings, accountUuids, overview);
                } else {
                    Timber.w("Unexpected start tag: %s", xpp.getName());
                }
            }
            eventType = xpp.next();
        }

        if (imported == null || (overview && imported.globalSettings == null && imported.accounts == null)) {
            throw new SettingsImportExportException("Invalid import data");
        }

        return imported;
    } catch (Exception e) {
        throw new SettingsImportExportException(e);
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:39,代码来源:SettingsImporter.java

示例12: Gpx2Fit

import org.xmlpull.v1.XmlPullParserFactory; //导入方法依赖的package包/类
public Gpx2Fit(String name, InputStream in, Gpx2FitOptions options) throws Exception {
    mGpx2FitOptions = options;
    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    factory.setNamespaceAware(true);
    XmlPullParser parser = factory.newPullParser();
    //parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
    courseName = name;
    BufferedInputStream inputStream = new BufferedInputStream(in);
    inputStream.mark(64000);

    //FileInputStream in = new FileInputStream(file);

    try {
        parser.setInput(inputStream, null);
        parser.nextTag();
        readGPX(parser);
        inputStream.close();
        return;
    } catch (Exception e) {
        ns = HTTP_WWW_TOPOGRAFIX_COM_GPX_1_0;
        Log.debug("Ex {}", e);
    }

    inputStream.reset();

    try {
        parser.setInput(inputStream, null);
        parser.nextTag();
        readGPX(parser);
    } finally {
        inputStream.close();
    }
}
 
开发者ID:gimportexportdevs,项目名称:gexporter,代码行数:34,代码来源:Gpx2Fit.java

示例13: SmoothStreamingManifestParser

import org.xmlpull.v1.XmlPullParserFactory; //导入方法依赖的package包/类
public SmoothStreamingManifestParser() {
  try {
    xmlParserFactory = XmlPullParserFactory.newInstance();
  } catch (XmlPullParserException e) {
    throw new RuntimeException("Couldn't create XmlPullParserFactory instance", e);
  }
}
 
开发者ID:MLNO,项目名称:airgram,代码行数:8,代码来源:SmoothStreamingManifestParser.java

示例14: getRootFilesFromContainer

import org.xmlpull.v1.XmlPullParserFactory; //导入方法依赖的package包/类
private static List<String> getRootFilesFromContainer(BufferedReader containerxml) {

        List<String> rootFiles = new ArrayList<>();

        try {

            containerxml.mark(4);
            if ('\ufeff' != containerxml.read()) containerxml.reset(); // not the BOM marker

            XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
            factory.setNamespaceAware(false);
            XmlPullParser xpp = factory.newPullParser();
            xpp.setInput(containerxml);

            int eventType = xpp.getEventType();
            while (eventType != XmlPullParser.END_DOCUMENT) {
                if (eventType == XmlPullParser.START_TAG) {
                    if (xpp.getName().equals("rootfile")) {
                        for (int i = 0; i < xpp.getAttributeCount(); i++) {
                            if (xpp.getAttributeName(i).equals("full-path")) {
                                rootFiles.add(xpp.getAttributeValue(i));
                            }
                        }
                    }

                }
                eventType = xpp.next();
            }
        } catch (Exception e) {
            Log.e("BMBF", "Error parsing xml " + e, e);
        }

        return rootFiles;

    }
 
开发者ID:quaap,项目名称:BookyMcBookface,代码行数:36,代码来源:EpubBook.java

示例15: createXmlPullParser

import org.xmlpull.v1.XmlPullParserFactory; //导入方法依赖的package包/类
@NonNull
private static XmlPullParser createXmlPullParser(@NonNull String tbodyXml) throws Throwable {
    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    factory.setNamespaceAware(true);
    XmlPullParser parser = factory.newPullParser();
    parser.setInput(new StringReader(tbodyXml));
    return parser;
}
 
开发者ID:powdream,项目名称:google-speech-api-android,代码行数:9,代码来源:SupportedLanguageConverter.java


注:本文中的org.xmlpull.v1.XmlPullParserFactory.newInstance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。