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