本文整理了Java中android.util.Xml.newPullParser()
方法的一些代码示例,展示了Xml.newPullParser()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Xml.newPullParser()
方法的具体详情如下:
包路径:android.util.Xml
类名称:Xml
方法名:newPullParser
暂无
代码示例来源:origin: facebook/stetho
private List<RssItem> parseRss(byte[] body) throws IOException, XmlPullParserException {
XmlPullParser parser = Xml.newPullParser();
parser.setInput(new ByteArrayInputStream(body), "UTF-8");
List<RssItem> items = new RssParser(parser).parse();
Log.d(TAG, "Fetched " + items.size() + " items");
return items;
}
代码示例来源:origin: evernote/android-job
/**
* Read an ArrayList from an InputStream containing XML. The stream can
* previously have been written by writeListXml().
*
* @param in The InputStream from which to read.
*
* @return ArrayList The resulting list.
*
* @see #readMapXml
* @see #readValueXml
* @see #readThisListXml
* @see #writeListXml
*/
public static final ArrayList readListXml(InputStream in)
throws XmlPullParserException, java.io.IOException {
XmlPullParser parser = Xml.newPullParser();
parser.setInput(in, null);
return (ArrayList) readValueXml(parser, new String[1]);
}
代码示例来源:origin: evernote/android-job
/**
* Read a HashMap from an InputStream containing XML. The stream can
* previously have been written by writeMapXml().
*
* @param in The InputStream from which to read.
*
* @return HashMap The resulting map.
*
* @see #readListXml
* @see #readValueXml
* @see #readThisMapXml
* #see #writeMapXml
*/
@SuppressWarnings("unchecked")
public static final HashMap<String, ?> readMapXml(InputStream in)
throws XmlPullParserException, java.io.IOException {
XmlPullParser parser = Xml.newPullParser();
parser.setInput(in, null);
return (HashMap<String, ?>) readValueXml(parser, new String[1]);
}
代码示例来源:origin: evernote/android-job
/**
* Read a HashSet from an InputStream containing XML. The stream can
* previously have been written by writeSetXml().
*
* @param in The InputStream from which to read.
*
* @return HashSet The resulting set.
*
* @throws XmlPullParserException
* @throws java.io.IOException
*
* @see #readValueXml
* @see #readThisSetXml
* @see #writeSetXml
*/
public static final HashSet readSetXml(InputStream in)
throws XmlPullParserException, java.io.IOException {
XmlPullParser parser = Xml.newPullParser();
parser.setInput(in, null);
return (HashSet) readValueXml(parser, new String[1]);
}
代码示例来源:origin: androidannotations/androidannotations
public static Set<String> deserialize(String data) {
Set<String> stringSet = new TreeSet<>();
XmlPullParser parser = Xml.newPullParser();
try {
parser.setInput(new StringReader(data));
parser.next();
parser.require(XmlPullParser.START_TAG, NAMESPACE, SET_TAG);
while (parser.next() != XmlPullParser.END_TAG) {
parser.require(XmlPullParser.START_TAG, NAMESPACE, STRING_TAG);
parser.next();
parser.require(XmlPullParser.TEXT, null, null);
stringSet.add(parser.getText());
parser.next();
parser.require(XmlPullParser.END_TAG, null, STRING_TAG);
}
} catch (XmlPullParserException e) {
Log.w("getStringSet", e);
return null;
} catch (IOException e) {
Log.w("getStringSet", e);
return null;
}
return stringSet;
}
}
代码示例来源:origin: Tencent/tinker
XmlPullParser parser = null;
try {
parser = Xml.newPullParser();
parser.setInput(sr);
int event = parser.getEventType();
代码示例来源:origin: android-hacker/VirtualXposed
try {
fis = userListFile.openRead();
XmlPullParser parser = Xml.newPullParser();
parser.setInput(fis, null);
int type;
代码示例来源:origin: android-hacker/VirtualXposed
new AtomicFile(new File(mUsersDir, Integer.toString(id) + ".xml"));
fis = userFile.openRead();
XmlPullParser parser = Xml.newPullParser();
parser.setInput(fis, null);
int type;
代码示例来源:origin: androidquery/androidquery
XmlPullParser parser = Xml.newPullParser();
try{
代码示例来源:origin: org.apache.chemistry.opencmis/chemistry-opencmis-android-client
/**
* Creates a new XML parser with OpenCMIS default settings.
*/
public static XmlPullParser createParser(InputStream stream) throws XmlPullParserException {
XmlPullParser parser = Xml.newPullParser();
parser.setInput(stream, IOUtils.UTF8);
return parser;
}
代码示例来源:origin: nvllsvm/Audinaut
void init(InputStream inputStream) throws Exception {
parser = Xml.newPullParser();
parser.setInput(inputStream, "UTF-8");
rootElementFound = false;
}
代码示例来源:origin: MeetMe/font-compat
public static Config parse(InputStream in) throws XmlPullParserException, IOException {
try {
XmlPullParser parser = Xml.newPullParser();
parser.setInput(in, null);
parser.nextTag();
return readFamilies(parser);
} finally {
in.close();
}
}
代码示例来源:origin: mzule/AndroidWeekly
public Dict parse() throws IOException, XmlPullParserException {
XmlPullParser parser = Xml.newPullParser();
parser.setInput(new URL(url).openStream(), null);
parser.nextTag();
dict = new Dict();
readDict(parser);
return dict;
}
代码示例来源:origin: PSDev/LicensesDialog
public static Notices parse(final InputStream inputStream) throws Exception {
try {
final XmlPullParser parser = Xml.newPullParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
parser.setInput(inputStream, null);
parser.nextTag();
return parse(parser);
} finally {
inputStream.close();
}
}
代码示例来源:origin: apps4av/avare
@Override
public List<Waypoint> parse(FileInputStream inputStream) {
try {
XmlPullParser parser = Xml.newPullParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
parser.setInput(inputStream, null);
parser.nextTag();
return readGPX(parser);
} catch (Exception e) { }
return null;
}
代码示例来源:origin: apps4av/avare
@Override
public ExternalFlightPlan parse(String fileName, FileInputStream inputStream) {
try {
XmlPullParser parser = Xml.newPullParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
parser.setInput(inputStream, null);
parser.nextTag();
return readGPX(parser);
} catch (Exception e) { }
return null;
}
代码示例来源:origin: apps4av/avare
@Override
public List<Waypoint> parse(FileInputStream inputStream) {
try {
XmlPullParser parser = Xml.newPullParser();
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
parser.setInput(inputStream, null);
parser.nextTag();
return readKmlData(parser);
} catch (Exception e) { }
return null;
}
代码示例来源:origin: NASAWorldWind/WorldWindAndroid
public static Object parse(InputStream inputStream) throws IOException, XmlPullParserException {
XmlPullParser pullParser = Xml.newPullParser();
pullParser.setInput(inputStream, null /*inputEncoding*/);
XmlModelParser modelParser = new OwsXmlParser();
modelParser.setPullParser(pullParser);
return modelParser.parse();
}
代码示例来源:origin: bjoernQ/unmock-plugin
@Test
public void testPullParser() throws Exception {
XmlPullParser pp = Xml.newPullParser();
pp.setInput(new StringReader("<a/>"));
pp.nextTag();
assertEquals("a", pp.getName());
}
代码示例来源:origin: bjoernQ/unmock-plugin
@Test
public void testPullParser() throws Exception {
XmlPullParser pp = Xml.newPullParser();
pp.setInput(new StringReader("<a/>"));
pp.nextTag();
assertEquals("a", pp.getName());
}
内容来源于网络,如有侵权,请联系作者删除!