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


Java Xml.newPullParser方法代码示例

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


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

示例1: Parse

import android.util.Xml; //导入方法依赖的package包/类
public List<RssItem> Parse(@NonNull InputStream inputStream) throws XmlPullParserException, IOException {
    try {
        XmlPullParser parser = Xml.newPullParser();

        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
        parser.setInput(inputStream, null);
        parser.nextTag();

        return readFeed(parser);
    } catch (Exception exception) {
        new SmartMirrorLogger(TAG).Error(exception.getMessage());
    } finally {
        inputStream.close();
    }

    return null;
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-MediaServer,代码行数:18,代码来源:RssParser.java

示例2: Parse

import android.util.Xml; //导入方法依赖的package包/类
public List<RssItem> Parse(@NonNull InputStream inputStream) throws XmlPullParserException, IOException {
    try {
        XmlPullParser parser = Xml.newPullParser();

        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
        parser.setInput(inputStream, null);
        parser.nextTag();

        return readFeed(parser);
    } catch (Exception exception) {
        Logger.getInstance().Error(TAG, exception.getMessage());
    } finally {
        inputStream.close();
    }

    return null;
}
 
开发者ID:GuepardoApps,项目名称:LucaHome-AndroidApplication,代码行数:18,代码来源:RssParser.java

示例3: FtcSongXml

import android.util.Xml; //导入方法依赖的package包/类
/**
 * Constructor: Create an instance of this object.
 *
 * @param instanceName specifies the instance name.
 * @param input specifies the input stream from which the notated song is read.
 */
public FtcSongXml(String instanceName, InputStream input) throws XmlPullParserException, IOException
{
    if (debugEnabled)
    {
        dbgTrace = new TrcDbgTrace(moduleName + "." + instanceName, tracingEnabled, traceLevel, msgLevel);
    }

    this.instanceName = instanceName;
    try
    {
        parser = Xml.newPullParser();
        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
        parser.setInput(input, null);
        parser.nextTag();
        parseCollection();
    }
    finally
    {
        input.close();
    }
}
 
开发者ID:trc492,项目名称:Ftc2018RelicRecovery,代码行数:28,代码来源:FtcSongXml.java

示例4: parse

import android.util.Xml; //导入方法依赖的package包/类
@NonNull
ArrayList<RssItem> parse(String stream) {
    ArrayList<RssItem> items = null;
    try {
        XmlPullParser parser = Xml.newPullParser();
        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
        parser.setInput(new StringReader(stream));
        parser.nextTag();
        parser.require(XmlPullParser.START_TAG, null, TAG_RSS);
        items = readFeed(parser);
    } catch (@NonNull XmlPullParserException | IOException e) {
        Log.w(e.getMessage(), e);
    } finally {
        if (items == null) {
            items = new ArrayList<>();
        }
    }
    return items;
}
 
开发者ID:MBach,项目名称:LeMondeRssReader,代码行数:20,代码来源:RssParser.java

示例5: parse

import android.util.Xml; //导入方法依赖的package包/类
public List<Response> parse(Reader in) throws XmlPullParserException, IOException {
    List<Response> responses = new ArrayList<Response>();

    XmlPullParser parser = Xml.newPullParser();

    parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES,true);
    parser.setInput(in);
    parser.nextTag();

    parser.require(XmlPullParser.START_TAG, ns, "multistatus");


    while (parser.next() != XmlPullParser.END_TAG) {
        android.util.Log.d("PARSE", "1eventtype=" + parser.getEventType());

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

        android.util.Log.d("PARSE", "1name = " + name);

        // Starts by looking for the entry tag
        if (name.equals("response")) {
            responses.add(readResponse(parser));
        } else {
            skip(parser);
        }
    }


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

示例6: parse

import android.util.Xml; //导入方法依赖的package包/类
public List<Cell> parse(InputStream in) throws XmlPullParserException, IOException {
    try {
        XmlPullParser parser = Xml.newPullParser();
        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
        parser.setInput(in, null);
        parser.nextTag();
        return readCells(parser);
    } finally {
        in.close();
    }
}
 
开发者ID:5GSD,项目名称:AIMSICDL,代码行数:12,代码来源:StackOverflowXmlParser.java

示例7: parse

import android.util.Xml; //导入方法依赖的package包/类
ZoneServer parse(final InputStream in) throws XmlPullParserException, IOException {
    try {
        XmlPullParser parser = Xml.newPullParser();
        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
        parser.setInput(in, null);
        parser.nextTag();
        return readZoneServer(parser);
    } finally {
        in.close();
    }
}
 
开发者ID:dkarivalis,项目名称:SWGEmuServerStatus,代码行数:12,代码来源:ZoneServerXmlParser.java

示例8: readContentByTag

import android.util.Xml; //导入方法依赖的package包/类
public static String readContentByTag(String xmlContent, String tag) {
    String content = null;
    if (!(TextUtils.isEmpty(xmlContent) || TextUtils.isEmpty(tag))) {
        InputStream inStream = new ByteArrayInputStream(xmlContent.getBytes());
        XmlPullParser parser = Xml.newPullParser();
        try {
            boolean isNeedEnd = false;
            for (int eventType = parser.getEventType(); eventType != 1 && !isNeedEnd; eventType = parser.next()) {
                switch (eventType) {
                    case 2:
                        if (!tag.equalsIgnoreCase(parser.getName())) {
                            break;
                        }
                        content = parser.nextText();
                        isNeedEnd = true;
                        break;
                    default:
                        break;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            LogInfo.log(TAG, "xml parser exception....");
        }
        try {
            inStream.close();
        } catch (IOException e2) {
            e2.printStackTrace();
        }
    }
    return content;
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:33,代码来源:XmlUtil.java

示例9: parseXmlResponse

import android.util.Xml; //导入方法依赖的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

示例10: loadStringsFromResourceFile

import android.util.Xml; //导入方法依赖的package包/类
private static void loadStringsFromResourceFile() {
    try {
        Resources res = UOctubreApplication.getInstance().getResources();
        InputStream in = res.getAssets().open("strings_" + currentLanguage + ".xml");
        XmlPullParser parser = Xml.newPullParser();
        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
        parser.setInput(in, null);
        parser.nextTag();
        readStrings(parser);
        in.close();

    } catch (XmlPullParserException | IOException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:mosquitolabs,项目名称:referendum_1o_android,代码行数:16,代码来源:StringsManager.java

示例11: parse

import android.util.Xml; //导入方法依赖的package包/类
private LocSample[] parse() throws XmlPullParserException, IOException {
    File f = new File(m_uri.getPath());
    try (FileInputStream s = new FileInputStream(f)){
        XmlPullParser parser = Xml.newPullParser();
        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
        parser.setInput(s, null);
        parser.nextTag();
        return readFeed(parser);
    }
}
 
开发者ID:ericberman,项目名称:MyFlightbookAndroid,代码行数:11,代码来源:Telemetry.java

示例12: parse

import android.util.Xml; //导入方法依赖的package包/类
public List parse(InputStream in) throws XmlPullParserException, IOException {
    try {
        XmlPullParser parser = Xml.newPullParser();
        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
        parser.setInput(in, null);
        parser.nextTag();
        return readFeed(parser);
    } finally {
        in.close();
    }
}
 
开发者ID:Recipe4Meals,项目名称:BLG-411E,代码行数:12,代码来源:IngredientsXMLParser.java

示例13: parse

import android.util.Xml; //导入方法依赖的package包/类
public LinkedList<Forecast> parse(InputStream in)
        throws XmlPullParserException, ParseException, IOException {
    try {
        XmlPullParser parser = Xml.newPullParser();
        parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
        parser.setInput(in, null);
        parser.nextTag();

        return readXmlFeed(parser);
    }
    finally {
        in.close();
    }
}
 
开发者ID:ec1oud,项目名称:sologyr,代码行数:15,代码来源:XMLParser.java

示例14: load

import android.util.Xml; //导入方法依赖的package包/类
private void load(String path, boolean fromAsset) throws IOException, XmlPullParserException
{
    InputStream in;
    if(fromAsset)
        in = SSJApplication.getAppContext().getAssets().open(path);
    else
        in = new FileInputStream(new File(STARTEGY_FOLDER, path));

    XmlPullParser parser = Xml.newPullParser();
    parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);

    parser.setInput(in, null);

    while(parser.next() != XmlPullParser.END_DOCUMENT)
    {
        switch(parser.getEventType())
        {
            case XmlPullParser.START_TAG:
                if(parser.getName().equalsIgnoreCase("strategy"))
                {
                    load(parser);
                }
                break;
        }
    }

    //find max progression level
    max_level = 0;
    for(FeedbackClass i : classes) {
        if(i.getLevel() > max_level)
            max_level = i.getLevel();
    }

    in.close();
}
 
开发者ID:hcmlab,项目名称:ssj,代码行数:36,代码来源:FeedbackManager.java

示例15: News

import android.util.Xml; //导入方法依赖的package包/类
public News(UpdateListener<List<String>> updateListener) {
  super(updateListener, UPDATE_INTERVAL_MILLIS);

  parser = Xml.newPullParser();
  try {
    parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
  } catch (XmlPullParserException e) {
    Log.e(TAG, "Failed to initialize XML parser.", e);
  }
}
 
开发者ID:maxbbraun,项目名称:mirror,代码行数:11,代码来源:News.java


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