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


Java XmlPullParser.setInput方法代码示例

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


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

示例1: xmlPullParserFromSocket

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
XmlPullParser xmlPullParserFromSocket(InputStream socketInputStream) throws IOException, XmlPullParserException {

	String line;
	StringBuilder xmlRpcText = new StringBuilder();
	BufferedReader br = new BufferedReader(new InputStreamReader(socketInputStream));
	while ((line = br.readLine()) != null && line.length() > 0); // eat the HTTP POST headers
	while (br.ready())
		xmlRpcText.append(br.readLine());
	// Log.d(Tag.LOG, "xml received:" + xmlRpcText.toString());
	
	InputStream inputStream = new ByteArrayInputStream(xmlRpcText.toString().getBytes("UTF-8"));
	XmlPullParser pullParser = XmlPullParserFactory.newInstance().newPullParser();
	Reader streamReader = new InputStreamReader(inputStream);
	pullParser.setInput(streamReader);
	return pullParser;
}
 
开发者ID:archos-sa,项目名称:aos-MediaLib,代码行数:17,代码来源:XMLRPCServer.java

示例2: Parse

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

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

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private void loadMainParts(String dateiname)
{
    try
    {
        XmlPullParser parser = new MXParser();
        FileReader reader = new FileReader(dateiname);
        parser.setInput(reader);

        processXML(parser);

        reader.close();
    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}
 
开发者ID:wolfposd,项目名称:IMSQTI2PDF,代码行数:18,代码来源:XmlParser.java

示例5: parse

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

示例6: getRootFilesFromContainer

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
private static List<String> getRootFilesFromContainer(BufferedReader containerxml) {

        List<String> rootFiles = new ArrayList<>();

        try {

            containerxml.mark(4);
            if ('\ufeff' != containerxml.read()) containerxml.reset(); // not the BOM marker

            XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
            factory.setNamespaceAware(false);
            XmlPullParser xpp = factory.newPullParser();
            xpp.setInput(containerxml);

            int eventType = xpp.getEventType();
            while (eventType != XmlPullParser.END_DOCUMENT) {
                if (eventType == XmlPullParser.START_TAG) {
                    if (xpp.getName().equals("rootfile")) {
                        for (int i = 0; i < xpp.getAttributeCount(); i++) {
                            if (xpp.getAttributeName(i).equals("full-path")) {
                                rootFiles.add(xpp.getAttributeValue(i));
                            }
                        }
                    }

                }
                eventType = xpp.next();
            }
        } catch (Exception e) {
            Log.e("BMBF", "Error parsing xml " + e, e);
        }

        return rootFiles;

    }
 
开发者ID:quaap,项目名称:BookyMcBookface,代码行数:36,代码来源:EpubBook.java

示例7: parse

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

示例8: load

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
@VisibleForTesting static SearchEngine load(String identifier, InputStream stream) throws IOException, XmlPullParserException {
    final SearchEngine searchEngine = new SearchEngine(identifier);

    XmlPullParser parser = XmlPullParserFactory.newInstance().newPullParser();
    parser.setInput(new InputStreamReader(stream, StandardCharsets.UTF_8));
    parser.next();

    readSearchPlugin(parser, searchEngine);

    return searchEngine;
}
 
开发者ID:mozilla-mobile,项目名称:firefox-tv,代码行数:12,代码来源:SearchEngineParser.java

示例9: parse

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

示例10: decodeXml

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
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,代码行数:35,代码来源:MainActivity.java

示例11: 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

示例12: parseXml

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
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,代码行数:29,代码来源:XmlElement.java

示例13: build

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
/**
 * @deprecated As of 1.4, use {@link XppDom#build(XmlPullParser)} instead
 */
@Deprecated
public static Xpp3Dom build(final Reader reader) throws Exception {
    final XmlPullParser parser = new MXParser();
    parser.setInput(reader);
    try {
        return (Xpp3Dom)XppDom.build(parser);
    } finally {
        reader.close();
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:Xpp3DomBuilder.java

示例14: load

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

示例15: parse

import org.xmlpull.v1.XmlPullParser; //导入方法依赖的package包/类
public static List<ItemRSS> parse(String rssFeed) throws XmlPullParserException, IOException {
    XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
    XmlPullParser xpp = factory.newPullParser();
    xpp.setInput(new StringReader(rssFeed));
    xpp.nextTag();
    return readRss(xpp);
}
 
开发者ID:if1001,项目名称:tarefa01-blaandrade,代码行数:8,代码来源:ParserRSS.java


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