Java Code Examples for org.xmlpull.v1.XmlPullParser#nextTag()
The following examples show how to use
org.xmlpull.v1.XmlPullParser#nextTag() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OPMLReadHelper.java From Focus with GNU General Public License v3.0 | 6 votes |
/** * 读取文件夹下的所有feed * @param parser * @param feedFolderName * @return * @throws IOException * @throws XmlPullParserException */ private List<Feed> readFeedFolderOutLine (XmlPullParser parser, String feedFolderName) throws IOException, XmlPullParserException { List<Feed> feedList = new ArrayList<>(); String type = parser.getAttributeValue(null, "type"); if (Objects.equals(type, "rss")) { feedList.add(parseFeed(parser, feedFolderName)); parser.nextTag(); } else { parser.require(XmlPullParser.START_TAG, null, OUTLINE); while (parser.next() != XmlPullParser.END_TAG) { if (parser.getEventType() != XmlPullParser.START_TAG) { continue; } String name = parser.getName(); if (name.equals(OUTLINE)) { feedList.addAll(readFeedFolderOutLine(parser, feedFolderName)); } else { skip(parser); } } } return feedList; }
Example 2
Source File: FreeOtpImporter.java From Aegis with GNU General Public License v3.0 | 6 votes |
@Override public State read(FileReader reader) throws DatabaseImporterException { try { XmlPullParser parser = Xml.newPullParser(); parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); parser.setInput(reader.getStream(), null); parser.nextTag(); List<JSONObject> entries = new ArrayList<>(); for (PreferenceParser.XmlEntry entry : PreferenceParser.parse(parser)) { if (!entry.Name.equals("tokenOrder")) { entries.add(new JSONObject(entry.Value)); } } return new State(entries); } catch (XmlPullParserException | IOException | JSONException e) { throw new DatabaseImporterException(e); } }
Example 3
Source File: WifiConfigStoreParser.java From WiFiKeyShare with GNU General Public License v3.0 | 6 votes |
private static String readTag(XmlPullParser parser, String tagName) throws IOException, XmlPullParserException { parser.require(XmlPullParser.START_TAG, null, tagName); String result = ""; if (parser.next() == XmlPullParser.TEXT) { result = parser.getText(); parser.nextTag(); } parser.require(XmlPullParser.END_TAG, null, tagName); if (tagName.equalsIgnoreCase("string") && Character.toString(result.charAt(0)).equals("\"") && Character.toString(result.charAt(result.length() - 1)).equals("\"")) { result = result.substring(1, result.length() - 1); } return result; }
Example 4
Source File: SimpleXmlParser.java From ssj with GNU General Public License v3.0 | 6 votes |
/** * @param parser XmlPullParser * @param depth int * @throws IOException * @throws XmlPullParserException */ private void readValues(XmlPullParser parser, int depth) throws IOException, XmlPullParserException { String name = searchPath[depth]; parser.require(XmlPullParser.START_TAG, namespace, name); if (searchAttributes == null) { xmlValues.foundTag.add(readText(parser)); } else { String tag = parser.getName(); if (tag.equals(name)) { String[] attributes = new String[searchAttributes.length]; for (int i = 0; i < searchAttributes.length; i++) { attributes[i] = parser.getAttributeValue(null, searchAttributes[i]); } xmlValues.foundAttributes.add(attributes); parser.nextTag(); } } }
Example 5
Source File: firmwareEntriesParser.java From SensorTag-CC2650 with Apache License 2.0 | 5 votes |
private float readFloat(XmlPullParser parser,String tag) throws XmlPullParserException, IOException { parser.require(XmlPullParser.START_TAG, ns, tag); float temp = 0.0f; if (parser.next() == XmlPullParser.TEXT) { temp = Float.parseFloat(parser.getText()); parser.nextTag(); } parser.require(XmlPullParser.END_TAG, ns, tag); return temp; }
Example 6
Source File: KeyChainSnapshotDeserializer.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private static String readText(XmlPullParser parser) throws IOException, XmlPullParserException { String result = ""; if (parser.next() == XmlPullParser.TEXT) { result = parser.getText(); parser.nextTag(); } return result; }
Example 7
Source File: PListParser.java From Connect-SDK-Android-Core with Apache License 2.0 | 5 votes |
public JSONObject parse(InputStream in) throws XmlPullParserException, IOException, JSONException { try { XmlPullParser parser = Xml.newPullParser(); parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); parser.setInput(in, null); parser.nextTag(); return readPlist(parser); } finally { in.close(); } }
Example 8
Source File: YahooXmlParser.java From Equate with GNU General Public License v3.0 | 5 votes |
private String readText(XmlPullParser parser) throws IOException, XmlPullParserException { String result = ""; if (parser.next() == XmlPullParser.TEXT){ result = parser.getText(); parser.nextTag(); } return result; }
Example 9
Source File: OPMLReadHelper_backup.java From Focus with GNU General Public License v3.0 | 5 votes |
private FeedFolder readOutline(XmlPullParser parser, String feedFolderName) throws IOException, XmlPullParserException { FeedFolder feedFolder = new FeedFolder(feedFolderName); String type = parser.getAttributeValue(null, "type"); if (Objects.equals(type, "rss")) {//只有一个订阅源,且没有分组 feedFolder.getFeedList().add(parseFeed(parser,feedFolderName)); parser.nextTag(); } else {//是一个文件夹 //我们只处理二级目录 feedFolder.getFeedList().addAll(readFeedFolderOutLine(parser,feedFolderName)); } return feedFolder; }
Example 10
Source File: ResourcesParser.java From Stringlate with MIT License | 5 votes |
static void loadFromXml(final InputStream in, final Resources resources, final XmlPullParser parser) throws XmlPullParserException, IOException { try { parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); parser.setInput(in, null); parser.nextTag(); readResourcesInto(parser, resources); } finally { try { in.close(); } catch (IOException ignored) { } } }
Example 11
Source File: UserLocationExtension.java From Yahala-Messenger with MIT License | 5 votes |
@Override public ExtensionElement parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException { /* String jid = parser.getAttributeValue(null, "jid"); String nodeId = parser.getAttributeValue(null, "node"); String subId = parser.getAttributeValue(null, "subid"); String state = parser.getAttributeValue(null, "subscription");*/ Double lon = 0d; Double lat = 0d; boolean done = false; while (!done) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { if ("lon".equalsIgnoreCase(parser.getName())) { String longValue = parser.nextText(); /* if (longValue.equals("0.0")) longValue="0";*/ lon = Double.parseDouble(longValue); parser.nextTag(); if ("lat".equalsIgnoreCase(parser.getName())) { String latValue = parser.nextText(); /* if (latValue.equals("0.0")) latValue="0";*/ lat = Double.parseDouble(latValue); } done = true; } } } return new UserLocationExtension(new Location(lon, lat)); }
Example 12
Source File: KmlParser.java From trekarta with GNU General Public License v3.0 | 5 votes |
private static float readFloat(XmlPullParser parser) throws IOException, XmlPullParserException { String text = ""; if (parser.next() == XmlPullParser.TEXT) { text = parser.getText(); parser.nextTag(); } float result; try { result = Float.parseFloat(text.trim()); } catch (NumberFormatException e) { throw new XmlPullParserException("Expected float", parser, e); } return result; }
Example 13
Source File: DLNAEventParser.java From Connect-SDK-Android-Core with Apache License 2.0 | 5 votes |
private JSONObject readEntry(String target, XmlPullParser parser) throws IOException, XmlPullParserException, JSONException { parser.require(XmlPullParser.START_TAG, ns, target); String value = parser.getAttributeValue(null, "val"); String channel = parser.getAttributeValue(null, "channel"); parser.nextTag(); parser.require(XmlPullParser.END_TAG, ns, target); JSONObject data = new JSONObject(); data.put(target, value); if (channel!=null) data.put("channel", channel); return data; }
Example 14
Source File: SimpleXmlParser.java From ssj with GNU General Public License v3.0 | 5 votes |
/** * @param parser XmlPullParser * @return String * @throws IOException * @throws XmlPullParserException */ private String readText(XmlPullParser parser) throws IOException, XmlPullParserException { String result = ""; if (parser.next() == XmlPullParser.TEXT) { result = parser.getText(); parser.nextTag(); } return result; }
Example 15
Source File: ECBXmlParser.java From Equate with GNU General Public License v3.0 | 5 votes |
/** * Parse a stream of XML data and extract currency rates and times. * @param stream input XML stream to parse * @return a HashMap of all the symbols and prices from the XML stream * @throws CurrencyParseException if there is any problem parsing the stream */ @Override protected HashMap<String, Entry> parse(InputStream stream) throws CurrencyParseException { try { XmlPullParser parser = Xml.newPullParser(); parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); parser.setInput(stream, null); parser.nextTag(); HashMap<String, Entry> euroBased = findSecondElement(parser); return convertEuroToDollar(euroBased); } catch (IOException | XmlPullParserException e) { throw new CurrencyParseException(e.getMessage()); } }
Example 16
Source File: OPMLReadHelper_backup.java From Focus with GNU General Public License v3.0 | 5 votes |
private FeedFolder readOutline(XmlPullParser parser, String feedFolderName) throws IOException, XmlPullParserException { FeedFolder feedFolder = new FeedFolder(feedFolderName); String type = parser.getAttributeValue(null, "type"); if (Objects.equals(type, "rss")) {//只有一个订阅源,且没有分组 feedFolder.getFeedList().add(parseFeed(parser,feedFolderName)); parser.nextTag(); } else {//是一个文件夹 //我们只处理二级目录 feedFolder.getFeedList().addAll(readFeedFolderOutLine(parser,feedFolderName)); } return feedFolder; }
Example 17
Source File: WISPAccessGatewayParam.java From WiFiAfterConnect with Apache License 2.0 | 5 votes |
public static WISPAccessGatewayParam parse (InputStream in) throws IOException { try { XmlPullParser parser = Xml.newPullParser(); parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false); parser.setInput(in, null); parser.nextTag(); return parse(parser); } catch (XmlPullParserException e) { // TODO Auto-generated catch block e.printStackTrace(); } return null; }
Example 18
Source File: BluetoothXmlParser.java From EFRConnect-android with Apache License 2.0 | 5 votes |
private long readLong(XmlPullParser parser) throws NumberFormatException, XmlPullParserException, IOException { long result = 0; if (parser.next() == XmlPullParser.TEXT) { result = Long.parseLong(parser.getText().trim()); parser.nextTag(); } return result; }
Example 19
Source File: GpxParser.java From trekarta with GNU General Public License v3.0 | 5 votes |
@NonNull private static String readText(XmlPullParser parser) throws IOException, XmlPullParserException { String result = ""; if (parser.next() == XmlPullParser.TEXT) { result = parser.getText(); parser.nextTag(); } return result; }
Example 20
Source File: WISPAccessGatewayParam.java From WiFiAfterConnect with Apache License 2.0 | 5 votes |
private static String readText(XmlPullParser parser) throws IOException, XmlPullParserException { String result = ""; if (parser.next() == XmlPullParser.TEXT) { result = parser.getText(); parser.nextTag(); } return result; }