当前位置: 首页>>代码示例>>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;未经允许,请勿转载。