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


Java XmlPullParser.START_DOCUMENT属性代码示例

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


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

示例1: readUuidData

private void readUuidData(XmlResourceParser xpp) throws XmlPullParserException, IOException {
  xpp.next();
  String tagName = null;
  String uuid = null;
  String descr = null;
  int eventType = xpp.getEventType();

  while (eventType != XmlPullParser.END_DOCUMENT) {
    if (eventType == XmlPullParser.START_DOCUMENT) {
      // do nothing
    } else if (eventType == XmlPullParser.START_TAG) {
      tagName = xpp.getName();
      uuid = xpp.getAttributeValue(null, "uuid");
      descr = xpp.getAttributeValue(null, "descr");
    } else if (eventType == XmlPullParser.END_TAG) {
      // do nothing
    } else if (eventType == XmlPullParser.TEXT) {
      if (tagName.equalsIgnoreCase("item")) {
        if (!uuid.isEmpty()) {
          uuid = uuid.replace("0x", "");
          mNameMap.put(uuid, xpp.getText());
          mDescrMap.put(uuid, descr);
        }
      }
    }
    eventType = xpp.next();
  }
}
 
开发者ID:UDOOboard,项目名称:UDOOBluLib-android,代码行数:28,代码来源:GattInfo.java

示例2: parse

/**
 * 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,代码行数:42,代码来源:GradleDependencyEntity.java

示例3: decodeXml

public Map<String,String> decodeXml(String content) {

		try {
			Map<String, String> xml = new HashMap<String, String>();
			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){
						//实例化student对象
						xml.put(nodeName,parser.nextText());
					}
					break;
				case XmlPullParser.END_TAG:
					break;
				}
				event = parser.next();
			}

			return xml;
		} catch (Exception e) {
			Log.e("Simon","----"+e.toString());
		}
		return null;

	}
 
开发者ID:gyqGitHub,项目名称:WeiXinPayDemo,代码行数:34,代码来源:MainActivity.java

示例4: executeAction

/**
 * {@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,代码行数:38,代码来源:AbstractGrammar.java

示例5: parseXml

public static XmlElement parseXml(InputStream in) throws XmlPullParserException, IOException {
    if (in == null) {
        return null;
    }
    
    XmlElement result = null;
    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    factory.setNamespaceAware(true);
    XmlPullParser xpp = factory.newPullParser();
    xpp.setInput(in, HTTP.UTF_8);
    int eventType = xpp.getEventType();
    while (eventType != XmlPullParser.END_DOCUMENT) {
        if (eventType == XmlPullParser.START_TAG) {
            result = new XmlElement(xpp.getName());
            result.parseXml(xpp);
        } else {
            try {
                if (eventType != XmlPullParser.START_DOCUMENT) {
                    LogUtils.w(XmlPullParser.TYPES[eventType]);
                }
            } catch (Throwable t) {
                LogUtils.e("Oh! My God!", t);
            }
        }
        eventType = xpp.next();
    }
    return result;
}
 
开发者ID:SavorGit,项目名称:Hotspot-master-devp,代码行数:28,代码来源:XmlElement.java

示例6: parseXmlResponse

/**
 * <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,代码行数:49,代码来源:OrderInfoUtil.java

示例7: parseApplicationNameByManifest

/**
 * 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,代码行数:38,代码来源:ApkManifestParser.java

示例8: parseBatchResponse

/**
 * Launches the parsing of the Batch Response only
 *
 * @throws XmlPullParserException if an error occurs in the parser
 */
public void parseBatchResponse() throws XmlPullParserException
{
    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;
        }
        
        try
        {
            eventType = xpp.next();
        }
        catch ( IOException ioe )
        {
            throw new XmlPullParserException( I18n.err( I18n.ERR_03037, ioe.getLocalizedMessage() ), xpp, ioe );
        }
    }
    while ( container.getState() != Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP );
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:46,代码来源:Dsmlv2ResponseParser.java

示例9: parseBatchRequest

/**
 * Launches the parsing of the Batch Request only
 *
 * @throws XmlPullParserException if an error occurs in the parser
 */
public void parseBatchRequest() throws XmlPullParserException
{
    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;
        }

        try
        {
            eventType = xpp.next();
        }
        catch ( IOException ioe )
        {
            throw new XmlPullParserException( I18n.err( I18n.ERR_03037, ioe.getLocalizedMessage() ), xpp, ioe );
        }
    }
    while ( container.getState() != Dsmlv2StatesEnum.BATCHREQUEST_START_TAG );

    BatchRequestDsml br = container.getBatchRequest();

    if ( br != null )
    {
        br.setStoreReq( storeMsgInBatchReq );
    }
}
 
开发者ID:apache,项目名称:directory-ldap-api,代码行数:53,代码来源:Dsmlv2Parser.java

示例10: getLPLinesFromXml

private List<LPLine> getLPLinesFromXml() throws IOException, XmlPullParserException {
    List<LPLine> list = null;
    LPLine line = null;
    InputStream is = App.getContext().getAssets().open("suzhoubus.xml");
    XmlPullParser xpp = Xml.newPullParser();
    xpp.setInput(is, "UTF-8");
    int eventType = xpp.getEventType();
    while (eventType != XmlPullParser.END_DOCUMENT) {
        switch (eventType) {
            case XmlPullParser.START_DOCUMENT:
                list = new ArrayList<>();
                break;
            case XmlPullParser.START_TAG:
                if (xpp.getName().equals("LPLine")) {
                    line = new LPLine();
                } else if (xpp.getName().equals("LPLineName")) {
                    xpp.next();
                    line.setName(xpp.getText());
                } else if (xpp.getName().equals("LPGUID")) {
                    xpp.next();
                    line.setId(xpp.getText());
                } else if (xpp.getName().equals("LPFStdName")) {
                    xpp.next();
                    line.setFromWhere(xpp.getText());
                } else if (xpp.getName().equals("LPEStdName")) {
                    xpp.next();
                    line.setToWhere(xpp.getText());
                } else if (xpp.getName().equals("LPFStdFTime")) {
                    xpp.next();
                    line.setStartTime(xpp.getText());
                } else if (xpp.getName().equals("LPFStdETime")) {
                    xpp.next();
                    line.setEndTime(xpp.getText());
                } else if (xpp.getName().equals("LPIntervalH")) {
                    xpp.next();
                    line.setMinTime(xpp.getText());
                } else if (xpp.getName().equals("LPIntervalN")) {
                    xpp.next();
                    line.setMaxTime(xpp.getText());
                } else if (xpp.getName().equals("LPDirection")) {
                    xpp.next();
                    line.setDirection(xpp.getText());
                } else if (xpp.getName().equals("LPLineDirect")) {
                    xpp.next();
                    line.setLineDirect(xpp.getText());
                } else if (xpp.getName().equals("LPStandName")) {
                    xpp.next();
                    line.setStations(xpp.getText());
                }
                break;

            case XmlPullParser.END_TAG:
                if (xpp.getName().equals("LPLine")) {
                    list.add(line);
                    line = null;
                }
                break;
        }
        eventType = xpp.next();
    }
    final Collator chineseCollator = Collator.getInstance(Locale.CHINA);
    Collections.sort(list, new Comparator<LPLine>() {
        @Override
        public int compare(LPLine o1, LPLine o2) {
            return chineseCollator.compare(o1.getName(), o2.getName());
        }
    });
    return list;
}
 
开发者ID:li-yu,项目名称:FakeWeather,代码行数:69,代码来源:AllLineActivity.java

示例11: loadFromXml

private void loadFromXml(int resourceId) {
    XmlResourceParser parser = getContext().getResources().getXml(
            resourceId);
    try {
        int eventType = parser.getEventType();
        while (eventType != XmlPullParser.END_DOCUMENT) {
            if (eventType == XmlPullParser.START_DOCUMENT) {

            } else if (eventType == XmlPullParser.START_TAG) {
                String name = parser.getName();
                if (!TextUtils.isEmpty(name) && name.equals("animation-list")) {
                    int size = parser.getAttributeCount();
                    for (int i = 0; i < size; i++) {
                        if (parser.getAttributeName(i).equals(
                                "oneshot")) {
                            mLoop = !parser.getAttributeBooleanValue(
                                    i, true);
                        }
                    }
                }
                if (parser.getName().equals("item")) {
                    for (int i = 0; i < parser.getAttributeCount(); i++) {
                        if (parser.getAttributeName(i).equals(
                                "drawable")) {
                            int resId = Integer.parseInt(parser
                                    .getAttributeValue(i)
                                    .substring(1));
                            if (resId != 0)
                                mRes.add(resId);
                        } else if (parser.getAttributeName(i)
                                .equals("duration")) {
                            duration = parser.getAttributeIntValue(
                                    i, 1000);
                        }
                    }
                }
            } else if (eventType == XmlPullParser.END_TAG) {
            } else if (eventType == XmlPullParser.TEXT) {
            }
            eventType = parser.next();
        }
    } catch (IOException e) {
        e.printStackTrace();
    } catch (XmlPullParserException e2) {
        e2.printStackTrace();
    }
}
 
开发者ID:ronghao,项目名称:FrameAnimationView,代码行数:47,代码来源:FrameAnimView.java

示例12: getManifestXMLFromAPK

/**
 * getManifestXMLFromAPK
 *
 * @param file  file
 * @param entry entry
 * @return str
 */
public static String getManifestXMLFromAPK(ZipFile file, ZipEntry entry) {
    StringBuilder xmlSb = new StringBuilder(100);
    XmlResourceParser parser = null;
    try {
        parser = new XmlResourceParser();
        parser.open(file.getInputStream(entry));

        StringBuilder sb = new StringBuilder(10);
        final String indentStep = "	";

        int type;
        while ((type = parser.next()) != XmlPullParser.END_DOCUMENT) {
            switch (type) {
                case XmlPullParser.START_DOCUMENT: {
                    log(xmlSb, "<?xml version=\"1.0\" encoding=\"utf-8\"?>");
                    break;
                }
                case XmlPullParser.START_TAG: {
                    log(false, xmlSb, "%s<%s%s", sb, getNamespacePrefix(parser.getPrefix()), parser.getName());
                    sb.append(indentStep);

                    int namespaceCountBefore = parser.getNamespaceCount(parser.getDepth() - 1);
                    int namespaceCount = parser.getNamespaceCount(parser.getDepth());

                    for (int i = namespaceCountBefore; i != namespaceCount; ++i) {
                        log(xmlSb, "%sxmlns:%s=\"%s\"", i == namespaceCountBefore ? "  " : sb,
                                parser.getNamespacePrefix(i), parser.getNamespaceUri(i));
                    }

                    for (int i = 0, size = parser.getAttributeCount(); i != size; ++i) {
                        log(false, xmlSb, "%s%s%s=\"%s\"", " ", getNamespacePrefix(parser.getAttributePrefix(i)),
                                parser.getAttributeName(i), getAttributeValue(parser, i));
                    }
                    // log("%s>",sb);
                    log(xmlSb, ">");
                    break;
                }
                case XmlPullParser.END_TAG: {
                    sb.setLength(sb.length() - indentStep.length());
                    log(xmlSb, "%s</%s%s>", sb, getNamespacePrefix(parser.getPrefix()), parser.getName());
                    break;
                }
                case XmlPullParser.TEXT: {
                    log(xmlSb, "%s%s", sb, parser.getText());
                    break;
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        parser.close();
    }
    return xmlSb.toString();
}
 
开发者ID:LiangMaYong,项目名称:android-apkbox,代码行数:62,代码来源:ApkManifestReader.java


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