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


Java XmlPullParser.getEventType方法代码示例

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


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

示例1: readChannel

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
public static List<ItemRSS> readChannel(XmlPullParser parser)
        throws IOException, XmlPullParserException {
    List<ItemRSS> items = new ArrayList<ItemRSS>();
    parser.require(XmlPullParser.START_TAG, null, "channel");
    while (parser.next() != XmlPullParser.END_TAG) {
        if (parser.getEventType() != XmlPullParser.START_TAG) {
            continue;
        }
        String name = parser.getName();
        if (name.equals("item")) {
            items.add(readItem(parser));
        } else {
            skip(parser);
        }
    }
    return items;
}
 
开发者ID:if1001,项目名称:tarefa01-blaandrade,代码行数:18,代码来源:ParserRSS.java

示例2: readDevice

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private void readDevice(XmlPullParser parser) throws XmlPullParserException, IOException {
    parser.require(XmlPullParser.START_TAG, ns, mDeviceName);
    mDevice = new OTADevice();
    while (parser.next() != XmlPullParser.END_TAG) {
        if (parser.getEventType() != XmlPullParser.START_TAG) {
            continue;
        }
        String tagName = parser.getName();
        if (tagName.equalsIgnoreCase(FILENAME_TAG)) {
            String tagValue = readTag(parser, tagName);
            mDevice.setLatestVersion(tagValue);
        } else if (isUrlTag(tagName)) {
            OTALink link = readLink(parser, tagName);
            mDevice.addLink(link);
        } else {
            skip(parser);
        }
    }
}
 
开发者ID:DroidThug,项目名称:VulcanOTA,代码行数:20,代码来源:OTAParser.java

示例3: readThisListXml

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static ArrayList readThisListXml(XmlPullParser parser, String endTag, String[] name)
        throws XmlPullParserException, IOException {
    ArrayList list = new ArrayList();

    int eventType = parser.getEventType();
    do {
        if (eventType == XmlPullParser.START_TAG) {
            Object val = readThisValueXml(parser, name);
            list.add(val);
        } else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals(endTag)) {
                return list;
            }
            throw new XmlPullParserException("Expected " + endTag + " end tag at: " + parser.getName());
        }
        eventType = parser.next();
    } while (eventType != XmlPullParser.END_DOCUMENT);

    throw new XmlPullParserException("Document ended before " + endTag + " end tag");
}
 
开发者ID:Doist,项目名称:JobSchedulerCompat,代码行数:22,代码来源:XmlUtils.java

示例4: skip

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
/**
 * skips a tag during parsing the xml string
 *
 * @param parser
 * @throws XmlPullParserException
 * @throws IOException
 */
private void skip(XmlPullParser parser) throws XmlPullParserException, IOException {
    if (parser.getEventType() != XmlPullParser.START_TAG) {
        throw new IllegalStateException();
    }
    int depth = 1;
    while (depth != 0) {
        switch (parser.next()) {
            case XmlPullParser.END_TAG:
                depth--;
                break;
            case XmlPullParser.START_TAG:
                depth++;
                break;
            default:
                break;
        }
    }
}
 
开发者ID:Webtrekk,项目名称:webtrekk-android-sdk,代码行数:26,代码来源:TrackingConfigurationXmlParser.java

示例5: readPropStat

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private Response.PropStat readPropStat(XmlPullParser parser) throws IOException, XmlPullParserException {
    Response.PropStat propstat = new Response.PropStat();
    parser.require(XmlPullParser.START_TAG, ns, "propstat");
    android.util.Log.d("PARSE", "readPropStat");
    while (parser.next() != XmlPullParser.END_TAG) {

        android.util.Log.d("PARSE", "3eventtype=" + parser.getEventType());

        if (parser.getEventType() != XmlPullParser.START_TAG) {
            continue;
        }
        String name = parser.getName();
        android.util.Log.d("PARSE", "3name=" + name);
        if (name.equals("prop"))
        {
            propstat.prop = readProp(parser);
        } else if (name.equals("status"))
        {
            propstat.status = readText(parser);
        } else {
            skip(parser);
        }
    }
    return propstat;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:26,代码来源:PropfindXmlParser.java

示例6: readThisMapXml

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
/**
 * Read a HashMap object from an XmlPullParser.  The XML data could
 * previously have been generated by writeMapXml().  The XmlPullParser
 * must be positioned <em>after</em> the tag that begins the map.
 *
 * @param parser The XmlPullParser from which to read the map data.
 * @param endTag Name of the tag that will end the map, usually "map".
 * @param name An array of one string, used to return the name attribute
 *             of the map's tag.
 *
 * @return HashMap The newly generated map.
 *
 * @see #readMapXml
 * @hide
 */
public static final HashMap<String, ?> readThisMapXml(XmlPullParser parser, String endTag,
        String[] name, ReadMapCallback callback)
        throws XmlPullParserException, java.io.IOException
{
    HashMap<String, Object> map = new HashMap<String, Object>();

    int eventType = parser.getEventType();
    do {
        if (eventType == parser.START_TAG) {
            Object val = readThisValueXml(parser, name, callback, false);
            map.put(name[0], val);
        } else if (eventType == parser.END_TAG) {
            if (parser.getName().equals(endTag)) {
                return map;
            }
            throw new XmlPullParserException(
                "Expected " + endTag + " end tag at: " + parser.getName());
        }
        eventType = parser.next();
    } while (eventType != parser.END_DOCUMENT);

    throw new XmlPullParserException(
        "Document ended before " + endTag + " end tag");
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:40,代码来源:XmlUtils.java

示例7: readFeatures

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private List<Features> readFeatures(XmlPullParser parser) throws XmlPullParserException {
    final List<Features> result = new ArrayList<>();
    try {
        parser.require(XmlPullParser.START_TAG, null, FEATURES);
        while(parser.next() != XmlPullParser.END_TAG){
            if(parser.getEventType() != XmlPullParser.START_TAG){
                continue;
            }

            String name = parser.getName();
            if (name.equals(FEATURES)) {
                result.add(Features.valueOf(readText(parser)));
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return result;
}
 
开发者ID:ABTSoftware,项目名称:SciChart.Android.Examples,代码行数:20,代码来源:ExampleDefinitionParser.java

示例8: readItem

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
public static ItemRSS readItem(XmlPullParser parser) throws XmlPullParserException, IOException {
    String title = null;
    String link = null;
    String pubDate = null;
    String description = null;
    parser.require(XmlPullParser.START_TAG, null, "item");
    while (parser.next() != XmlPullParser.END_TAG) {
        if (parser.getEventType() != XmlPullParser.START_TAG) {
            continue;
        }
        String name = parser.getName();
        if (name.equals("title")) {
            title = readData(parser, "title");
        } else if (name.equals("link")) {
            link = readData(parser, "link");
        } else if (name.equals("pubDate")) {
            pubDate = readData(parser, "pubDate");
        } else if (name.equals("description")) {
            description = readData(parser, "description");
        } else {
            skip(parser);
        }
    }
    ItemRSS result = new ItemRSS(title, link, pubDate, description);
    return result;
}
 
开发者ID:if1001,项目名称:tarefa01-blaandrade,代码行数:27,代码来源:ParserRSS.java

示例9: executeAction

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void executeAction( Dsmlv2Container container ) throws XmlPullParserException, IOException
{
    XmlPullParser xpp = container.getParser();

    int eventType = xpp.getEventType();

    do
    {
        switch ( eventType )
        {
            case XmlPullParser.START_DOCUMENT:
                container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE );
                break;

            case XmlPullParser.END_DOCUMENT:
                container.setState( Dsmlv2StatesEnum.GRAMMAR_END );
                break;

            case XmlPullParser.START_TAG:
                processTag( container, Tag.START );
                break;

            case XmlPullParser.END_TAG:
                processTag( container, Tag.END );
                break;

            default:
                break;
        }

        eventType = xpp.next();
    }
    while ( eventType != XmlPullParser.END_DOCUMENT );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:39,代码来源:AbstractGrammar.java

示例10: parseApplicationNameByManifest

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
/**
 * get application name by manifest
 *
 * @param parser parser
 * @return application name
 */
private static String parseApplicationNameByManifest(XmlPullParser parser) {
    try {
        int eventType = parser.getEventType();
        String namespaceAndroid = null;
        do {
            switch (eventType) {
                case XmlPullParser.START_DOCUMENT: {
                    break;
                }
                case XmlPullParser.START_TAG: {
                    String tag = parser.getName();
                    if (tag.equals("manifest")) {
                        namespaceAndroid = parser.getNamespace("android");
                    } else if ("application".equals(parser.getName())) {
                        String applicationName = parser.getAttributeValue("", "name");
                        if (applicationName == null || "".equals(applicationName)) {
                            applicationName = parser.getAttributeValue(namespaceAndroid, "name");
                        }
                        return applicationName;
                    }
                    break;
                }
                case XmlPullParser.END_TAG: {
                    break;
                }
            }
            eventType = parser.next();
        } while (eventType != XmlPullParser.END_DOCUMENT);
    } catch (Exception e1) {
    }
    return "";
}
 
开发者ID:LiangMaYong,项目名称:android-apkbox,代码行数:39,代码来源:ApkManifestParser.java

示例11: parse

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的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

示例12: readExampleDefinition

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private ExampleDefinition readExampleDefinition(XmlPullParser parser) throws IOException, XmlPullParserException {
    parser.require(XmlPullParser.START_TAG, null, EXAMPLE_DEFINITION);
    String title = "";
    String iconPath = "";
    String description = "";
    final List<String> codeFiles = new ArrayList<>();
    final List<Features> features = new ArrayList<>();
    boolean isVisible = false;
    while (parser.next() != XmlPullParser.END_TAG) {
        if (parser.getEventType() != XmlPullParser.START_TAG) {
            continue;
        }
        final String name = parser.getName();
        switch (name) {
            case TITLE:
                title = readElement(parser, TITLE);
                break;
            case ICON_PATH:
                iconPath = readElement(parser, ICON_PATH);
                break;
            case DESCRIPTION:
                description = parseDescription(readElement(parser, DESCRIPTION));
                break;
            case CODE_FILES:
                codeFiles.addAll(readCodeFiles(parser));
                break;
            case FEATURES:
                features.addAll(readFeatures(parser));
                break;
            case IS_VISIBLE:
                isVisible = Boolean.parseBoolean(readElement(parser, IS_VISIBLE));
                break;
            default:
                skip(parser);
                break;
        }
    }
    return new ExampleDefinition(title, "", "", iconPath, description, codeFiles, features, isVisible);
}
 
开发者ID:ABTSoftware,项目名称:SciChart.Android.Examples,代码行数:40,代码来源:ExampleDefinitionParser.java

示例13: readProp

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private Response.PropStat.Prop readProp(XmlPullParser parser) throws IOException, XmlPullParserException {
    Response.PropStat.Prop prop = new Response.PropStat.Prop();
    parser.require(XmlPullParser.START_TAG, ns, "prop");
    android.util.Log.d("PARSE", "readProp");
    while (parser.next() != XmlPullParser.END_TAG) {
        android.util.Log.d("PARSE", "eventtype=" + parser.getEventType());

        if (parser.getEventType() != XmlPullParser.START_TAG) {
            continue;
        }
        String name = parser.getName();

        android.util.Log.d("PARSE", "4name = " + name);
        if (name.equals("getcontentlength"))
        {
            prop.ContentLength = readText(parser);
        } else if (name.equals("getlastmodified")) {
            prop.LastModified = readText(parser);
        } else if (name.equals("displayname")) {
            prop.DisplayName = readText(parser);
        } else {
            skip(parser);
        }
    }

    return  prop;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:28,代码来源:PropfindXmlParser.java

示例14: readStrings

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private static void readStrings(XmlPullParser parser) throws XmlPullParserException, IOException {
    parser.require(XmlPullParser.START_TAG, null, "resources");
    while (parser.next() != XmlPullParser.END_TAG) {
        if (parser.getEventType() != XmlPullParser.START_TAG) {
            continue;
        }
        String name = parser.getName();
        if (name.equals("string")) {
            readString(parser);
        } else {
            skip(parser);
        }
    }
}
 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:15,代码来源:StringsManager.java

示例15: parseXmlResponse

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
/**
 * <xml>
 * <return_code><![CDATA[SUCCESS]]></return_code>
 * <return_msg><![CDATA[OK]]></return_msg>
 * <appid><![CDATA[wx2421b1c4370ec43b]]></appid>
 * <mch_id><![CDATA[10000100]]></mch_id>
 * <nonce_str><![CDATA[IITRi8Iabbblz1Jc]]></nonce_str>
 * <sign><![CDATA[7921E432F65EB8ED0CE9755F0E86D72F]]></sign>
 * <result_code><![CDATA[SUCCESS]]></result_code>
 * <prepay_id><![CDATA[wx201411101639507cbf6ffd8b0779950874]]></prepay_id>
 * <trade_type><![CDATA[APP]]></trade_type>
 * </xml>
 * 解析统一下单返回的xml报文
 *
 * @param content 统一下单返回的xml字符串
 *
 * @return 解析完的map
 */
public static Map<String, String> parseXmlResponse(String content) {
    try {
        Map<String, String> xml = new HashMap<>();
        XmlPullParser parser = Xml.newPullParser();
        parser.setInput(new StringReader(content));
        int event = parser.getEventType();
        while (event != XmlPullParser.END_DOCUMENT) {

            String nodeName = parser.getName();
            switch (event) {
                case XmlPullParser.START_DOCUMENT:
                    break;
                case XmlPullParser.START_TAG:
                    if ("xml".equals(nodeName) == false) {
                        // 实例化对象
                        xml.put(nodeName, parser.nextText());
                    }
                    break;
                case XmlPullParser.END_TAG:
                    break;
            }
            event = parser.next();
        }
        return xml;
    } catch (Exception e) {
        if (Wxpay.DEBUG) {
            Wxpay.log("无法从xml中解析统一下单信息:" + e.toString());
        }
    }
    return null;
}
 
开发者ID:Jamling,项目名称:af-pay,代码行数:50,代码来源:OrderInfoUtil.java


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