當前位置: 首頁>>代碼示例>>Java>>正文


Java XmlPullParserFactory.newPullParser方法代碼示例

本文整理匯總了Java中org.xmlpull.v1.XmlPullParserFactory.newPullParser方法的典型用法代碼示例。如果您正苦於以下問題:Java XmlPullParserFactory.newPullParser方法的具體用法?Java XmlPullParserFactory.newPullParser怎麽用?Java XmlPullParserFactory.newPullParser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.xmlpull.v1.XmlPullParserFactory的用法示例。


在下文中一共展示了XmlPullParserFactory.newPullParser方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: Dsmlv2Parser

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
/**
 * Creates a new instance of Dsmlv2Parser.
 *
 * @param storeMsgInBatchReq flag to set if the parsed requests should b stored
 * @throws XmlPullParserException if an error occurs during the initialization of the parser
 */
public Dsmlv2Parser( boolean storeMsgInBatchReq ) throws XmlPullParserException
{
    this.storeMsgInBatchReq = storeMsgInBatchReq;

    this.grammar = new Dsmlv2Grammar();
    this.container = new Dsmlv2Container( grammar.getLdapCodecService() );

    this.container.setGrammar( grammar );

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

    container.setParser( xpp );
}
 
開發者ID:apache,項目名稱:directory-ldap-api,代碼行數:22,代碼來源:Dsmlv2Parser.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: getXmlPullParser

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
public static XmlPullParser getXmlPullParser(Resources resources, String packageName, String file) throws XMLNotFoundException, XmlPullParserException {

        XmlPullParser xpp = null;

        int xmlId = resources.getIdentifier(file, DEF_XML, packageName);

        if (xmlId > 0) {
            xpp = resources.getXml(xmlId);
        } else {
            // no resource found, try to open it from assets folder
            try {
                InputStream appfilterstream = resources.getAssets().open(file + EXT_XML);

                XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
                factory.setNamespaceAware(true);
                xpp = factory.newPullParser();
                xpp.setInput(appfilterstream, UTF_8);
            } catch (IOException e) {
                throw new XMLNotFoundException(file + EXT_XML, e);
            }
        }
        return xpp;
    }
 
開發者ID:sofakingforever,項目名稱:IconPackParser-Android,代碼行數:24,代碼來源:XmlPullParserGenerator.java

示例4: 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

示例5: parseXml

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
protected void parseXml(InputStream inputStream)
		throws XmlPullParserException, IOException
{
	mStack.clear();

	XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
	factory.setNamespaceAware(false);

	XmlPullParser parser = factory.newPullParser();
	parser.setInput(inputStream, "UTF-8");
	parser.setFeature(Xml.FEATURE_RELAXED, true);

	int eventType = parser.getEventType();
	while (eventType != XmlPullParser.END_DOCUMENT) {
		if (eventType == XmlPullParser.START_TAG) {
			mStack.push(parser.getName());
			onStartElement(new SimpleXmlPath(mStack), parser);
		} else if (eventType == XmlPullParser.END_TAG) {
			mStack.pop();
		} else if (eventType == XmlPullParser.TEXT) {
			onTextContent(new SimpleXmlPath(mStack), parser.getText());
		}

		eventType = parser.next();
	}
}
 
開發者ID:0xe1f,項目名稱:ararat,代碼行數:27,代碼來源:SimpleXmlParser.java

示例6: 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:veryyoung,項目名稱:WechatLuckyMoney,代碼行數:27,代碼來源:XmlToJson.java

示例7: getXMLFile

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
/**
 * This method returns an xml parser fed by the first existing file found from the path send as parameters.
 */
public static XmlPullParserHolder getXMLFile(String... filenames) throws XmlPullParserException, FileNotFoundException {
    if (filenames != null) {
        for (String filename : filenames) {
            // get a reference to the file.
            File file = new File(filename);
            if (file.exists()) {
                // if the file exists than we create the parser and return the instance
                XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
                factory.setNamespaceAware(true);
                XmlPullParser xpp = factory.newPullParser();

                // create an input stream to be read by the stream reader.
                FileInputStream fis = new FileInputStream(file);

                // set the input for the parser using an InputStreamReader
                xpp.setInput(new InputStreamReader(fis));
                return new XmlPullParserHolder(xpp, fis);
            }
            // If the file was not found than continue to iterate until all paths are checked
        }
    }

    // If there is no file found then throw an exception
    throw new FileNotFoundException("No XML file was found to load");
}
 
開發者ID:Last-Mile-Health,項目名稱:ODK-Liberia,代碼行數:29,代碼來源:XmlParserUtils.java

示例8: 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

示例9: 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

示例10: downloadGalleryItems

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
private ArrayList<Photo> downloadGalleryItems(String url) {
    ArrayList<Photo> items = new ArrayList<>();
    try {
        String xmlString = getUrl(url);
        Timber.i("Received xml: " + xmlString);
        XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
        XmlPullParser parser = factory.newPullParser();
        parser.setInput(new StringReader(xmlString));
        parseItems(items, parser);
    } catch (IOException ioe) {
        Timber.e("Failed to fetch items", ioe);
    } catch (XmlPullParserException xppe) {
        Timber.e("Failed to parse items", xppe);
    }
    return items;
}
 
開發者ID:matthew-compton,項目名稱:PhotoGalleryPlusPlus,代碼行數:17,代碼來源:FlickrFetchr.java

示例11: fetchPhotosets

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
/**
     * A method to get a list of photoset
     * @param url  url
     * @return  a list of photoset
     */
    public static ArrayList<Photoset> fetchPhotosets(String url){
        ArrayList<Photoset> _photosets = 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));

            parsePhotosets(_photosets, _xmlPullParser);                       /**Parser the xml String*/


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

        return _photosets;
    }
 
開發者ID:TwentySevenC,項目名稱:Flickr-Photos,代碼行數:29,代碼來源:FlickrUtils.java

示例12: 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

示例13: parse

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
/**
 * xml解析為對象
 *
 * @param text
 * @return
 */
public static GradleDependencyEntity parse(String text) {
    GradleDependencyEntity entity = new GradleDependencyEntity();
    XmlPullParserFactory f = null;
    try {
        f = XmlPullParserFactory.newInstance();
        f.setNamespaceAware(true);
        XmlPullParser xmlPullParser = f.newPullParser();
        xmlPullParser.setInput(new InputStreamReader(new ByteArrayInputStream(text.getBytes())));
        int eventType = xmlPullParser.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_DOCUMENT) {

            } else if (eventType == XmlPullParser.START_TAG) {
                String name = xmlPullParser.getName();
                if (name.equals("groupId")) {
                    entity.setGroupId(xmlPullParser.nextText());
                } else if (name.equals("artifactId")) {
                    entity.setArtifactId(xmlPullParser.nextText());
                } else if (name.equals("version")) {
                    String version = xmlPullParser.nextText();
                    entity.setVersion(version);
                } else if (name.equals("lastUpdated")) {
                    entity.setUpdateTime(xmlPullParser.nextText());
                }
            } else if (eventType == XmlPullParser.END_TAG) {

            } else if (eventType == XmlPullParser.TEXT) {

            }
            eventType = xmlPullParser.next();
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    return entity;
}
 
開發者ID:beansoftapp,項目名稱:react-native-console,代碼行數:43,代碼來源:GradleDependencyEntity.java

示例14: Dsmlv2ResponseParser

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
/**
 * Creates a new instance of Dsmlv2ResponseParser.
 *
 * @param codec The Ldap Service to use
 * @throws XmlPullParserException if an error occurs while the initialization of the parser
 */
public Dsmlv2ResponseParser( LdapApiService codec ) throws XmlPullParserException
{
    this.container = new Dsmlv2Container( codec );

    this.container.setGrammar( Dsmlv2ResponseGrammar.getInstance() );

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

    container.setParser( xpp );
}
 
開發者ID:apache,項目名稱:directory-ldap-api,代碼行數:19,代碼來源:Dsmlv2ResponseParser.java

示例15: load

import org.xmlpull.v1.XmlPullParserFactory; //導入方法依賴的package包/類
/***
 * Public method that loads settings values from XML file
 * @throws XmlPullParserException
 * @throws IOException
 */
public void load() throws XmlPullParserException, IOException {

    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    factory.setNamespaceAware(true);
    XmlPullParser parser = factory.newPullParser();
    parser.setInput(new StringReader(getFileContent(URI)));
    parser.nextTag();

    settings = readFeed(parser);
}
 
開發者ID:Visions-Team,項目名稱:eBread,代碼行數:16,代碼來源:SettingManager.java


注:本文中的org.xmlpull.v1.XmlPullParserFactory.newPullParser方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。