當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。