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