本文整理汇总了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;
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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);
}
}