Java Code Examples for org.xmlpull.v1.XmlPullParser#END_TAG
The following examples show how to use
org.xmlpull.v1.XmlPullParser#END_TAG .
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: XMLTVParser.java From ChannelSurfer with MIT License | 6 votes |
private static List<Program> createTV(XmlPullParser xpp) throws IOException, XmlPullParserException { Log.d(TAG, "Created TV parsings"); List<Program> entries = new ArrayList<>(); int eventType = xpp.next(); String n = ""; if(xpp.getName() != null) n = xpp.getName(); while (!(eventType == XmlPullParser.END_TAG && n.equals(TV))) { if (eventType == XmlPullParser.START_TAG) { // Log.d(TAG, "Found tag '"+xpp.getName()+"'"); if(xpp.getName().equals(PROGRAM)) { entries.add(createProgramme(xpp)); } } eventType = xpp.next(); if(xpp.getName() != null) n = xpp.getName(); } return entries; }
Example 2
Source File: ImportFileUpdater.java From alfresco-repository with GNU Lesser General Public License v3.0 | 6 votes |
public void doWork(XmlPullParser reader, XMLWriter writer) throws Exception { // Deal with the contents of the tag int eventType = reader.getEventType(); while (eventType != XmlPullParser.END_TAG) { eventType = reader.next(); if (eventType == XmlPullParser.START_TAG) { ImportFileUpdater.this.outputCurrentElement(reader, writer, new OutputChildren()); } else if (eventType == XmlPullParser.TEXT) { // Write the text to the output file writer.write(reader.getText()); } } }
Example 3
Source File: PullSOAPActionProcessorImpl.java From TVRemoteIME with GNU General Public License v2.0 | 6 votes |
protected void readBodyResponse(XmlPullParser xpp, ActionInvocation actionInvocation) throws Exception { // We're in the "Body" tag int event; do { event = xpp.next(); if (event == XmlPullParser.START_TAG) { if (xpp.getName().equals("Fault")) { ActionException e = readFaultElement(xpp); actionInvocation.setFailure(e); return; } else if (xpp.getName().equals(actionInvocation.getAction().getName() + "Response")) { readActionOutputArguments(xpp, actionInvocation); return; } } } while (event != XmlPullParser.END_DOCUMENT && (event != XmlPullParser.END_TAG || !xpp.getName().equals("Body"))); throw new ActionException( ErrorCode.ACTION_FAILED, String.format("Action SOAP response do not contain %s element", actionInvocation.getAction().getName() + "Response" ) ); }
Example 4
Source File: BluetoothXmlParser.java From EFRConnect-android with Apache License 2.0 | 6 votes |
private Characteristic readCharacteristic(XmlPullParser parser) throws XmlPullParserException, IOException { parser.require(XmlPullParser.START_TAG, ns, Consts.TAG_CHARACTERISTIC); Characteristic characteristic = new Characteristic(); String characteristicName = readCharacteristicName(parser); characteristic.setName(characteristicName); while (parser.next() != XmlPullParser.END_TAG) { if (parser.getEventType() != XmlPullParser.START_TAG) { continue; } String name = parser.getName(); if (name.equals(Consts.TAG_INFORMATIVE_TEXT)) { String summary = readSummary(parser); characteristic.setSummary(summary); } else if (name.equals(Consts.TAG_VALUE)) { ArrayList<Field> fields = readFieldValue(parser, characteristic); } else { skip(parser); } } return characteristic; }
Example 5
Source File: XmlParser.java From react-native-3d-model-view with MIT License | 6 votes |
private static void loadNode(XmlPullParser xpp, XmlNode parentNode) throws XmlPullParserException, IOException { int eventType = xpp.next(); while(eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG) { XmlNode childNode = new XmlNode(xpp.getName()); for (int i=0; i<xpp.getAttributeCount(); i++){ childNode.addAttribute(xpp.getAttributeName(i), xpp.getAttributeValue(i)); } parentNode.addChild(childNode); loadNode(xpp, childNode); } else if (eventType == XmlPullParser.END_TAG) { return; } else if (eventType == XmlPullParser.TEXT) { parentNode.setData(xpp.getText()); } eventType = xpp.next(); } }
Example 6
Source File: FontListParser.java From font-compat with Apache License 2.0 | 6 votes |
private static Family readFamily(XmlPullParser parser) throws XmlPullParserException, IOException { String name = parser.getAttributeValue(null, "name"); String lang = parser.getAttributeValue(null, "lang"); String variant = parser.getAttributeValue(null, "variant"); List<Font> fonts = new ArrayList<>(); while (parser.next() != XmlPullParser.END_TAG) { if (parser.getEventType() != XmlPullParser.START_TAG) continue; String tag = parser.getName(); if (tag.equals("font")) { String weightStr = parser.getAttributeValue(null, "weight"); int weight = weightStr == null ? 400 : Integer.parseInt(weightStr); boolean isItalic = "italic".equals(parser.getAttributeValue(null, "style")); String filename = parser.nextText(); fonts.add(new Font(filename, weight, isItalic)); } else { skip(parser); } } return new Family(name, fonts, lang, variant); }
Example 7
Source File: WifiConfigStoreParser.java From WiFiKeyShare with GNU General Public License v3.0 | 6 votes |
private static void skip(XmlPullParser parser) throws XmlPullParserException, IOException { if (parser.getEventType() != XmlPullParser.START_TAG) { throw new IllegalStateException(); } int depth = 1; while (depth != 0) { switch (parser.next()) { case XmlPullParser.END_TAG: depth--; break; case XmlPullParser.START_TAG: depth++; break; } } }
Example 8
Source File: XmlUtils.java From JobSchedulerCompat with MIT License | 6 votes |
private static HashMap<String, ?> readThisMapXml(XmlPullParser parser, String endTag, String[] name) throws XmlPullParserException, IOException { HashMap<String, Object> map = new HashMap<>(); int eventType = parser.getEventType(); do { if (eventType == XmlPullParser.START_TAG) { Object val = readThisValueXml(parser, name); map.put(name[0], val); } else if (eventType == XmlPullParser.END_TAG) { if (parser.getName().equals(endTag)) { return map; } throw new XmlPullParserException("Expected " + endTag + " end tag at: " + parser.getName()); } eventType = parser.next(); } while (eventType != XmlPullParser.END_DOCUMENT); throw new XmlPullParserException("Document ended before " + endTag + " end tag"); }
Example 9
Source File: PluginManifestUtil.java From AndroidPlugin with MIT License | 5 votes |
private static void setAttrs(PlugInfo info, String manifestXML) throws XmlPullParserException, IOException { XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); factory.setNamespaceAware(true); XmlPullParser parser = factory.newPullParser(); parser.setInput(new StringReader(manifestXML)); int eventType = parser.getEventType(); String namespaceAndroid = null; do { switch (eventType) { case XmlPullParser.START_DOCUMENT: { break; } case XmlPullParser.START_TAG: { String tag = parser.getName(); if (tag.equals("manifest")) { namespaceAndroid = parser.getNamespace("android"); } else if ("activity".equals(parser.getName())) { addActivity(info, namespaceAndroid, parser); } else if ("receiver".equals(parser.getName())) { addReceiver(info, namespaceAndroid, parser); } else if ("service".equals(parser.getName())) { addService(info, namespaceAndroid, parser); } else if ("application".equals(parser.getName())) { parseApplicationInfo(info, namespaceAndroid, parser); } break; } case XmlPullParser.END_TAG: { break; } } eventType = parser.next(); } while (eventType != XmlPullParser.END_DOCUMENT); }
Example 10
Source File: XmlUtils.java From PreferenceFragment with Apache License 2.0 | 5 votes |
public static void skipCurrentTag(XmlPullParser parser) throws XmlPullParserException, IOException { int outerDepth = parser.getDepth(); int type; while ((type=parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { } }
Example 11
Source File: XmlConfigSource.java From cwac-netsecurity with Apache License 2.0 | 5 votes |
private Pin parsePin(XmlResourceParser parser) throws IOException, XmlPullParserException, ParserException { String digestAlgorithm = parser.getAttributeValue(null, "digest"); if (!Pin.isSupportedDigestAlgorithm(digestAlgorithm)) { throw new ParserException(parser, "Unsupported pin digest algorithm: " + digestAlgorithm); } if (parser.next() != XmlPullParser.TEXT) { throw new ParserException(parser, "Missing pin digest"); } String digest = parser.getText().trim(); byte[] decodedDigest = null; try { decodedDigest = Base64.decode(digest, 0); } catch (IllegalArgumentException e) { throw new ParserException(parser, "Invalid pin digest", e); } int expectedLength = Pin.getDigestLength(digestAlgorithm); if (decodedDigest.length != expectedLength) { throw new ParserException(parser, "digest length " + decodedDigest.length + " does not match expected length for " + digestAlgorithm + " of " + expectedLength); } if (parser.next() != XmlPullParser.END_TAG) { throw new ParserException(parser, "pin contains additional elements"); } return new Pin(digestAlgorithm, decodedDigest); }
Example 12
Source File: MucKick.java From xyTalk-pc with GNU Affero General Public License v3.0 | 5 votes |
@Override public MucKick parse(org.xmlpull.v1.XmlPullParser parser, int initialDepth) throws org.xmlpull.v1.XmlPullParserException, IOException, SmackException { final MucKick result = new MucKick(); while ( true ) { parser.next(); String elementName = parser.getName(); switch ( parser.getEventType() ) { case XmlPullParser.START_TAG: if ( "roomid".equals( elementName ) ) { result.setRoomid( parser.nextText() ); } if ( "roomName".equals( elementName ) ) { result.setRoomName(parser.nextText() ); } break; case XmlPullParser.END_TAG: if ( ELEMENT_NAME.equals( elementName ) ) { return result; } break; } } }
Example 13
Source File: PackageParser.java From AndroidComponentPlugin with Apache License 2.0 | 5 votes |
private boolean parseAllMetaData(Resources res, XmlPullParser parser, AttributeSet attrs, String tag, Component outInfo, String[] outError) throws XmlPullParserException, IOException { int outerDepth = parser.getDepth(); int type; while ((type=parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { if (type == XmlPullParser.END_TAG || type == XmlPullParser.TEXT) { continue; } if (parser.getName().equals("meta-data")) { if ((outInfo.metaData=parseMetaData(res, parser, attrs, outInfo.metaData, outError)) == null) { return false; } } else { if (!RIGID_PARSER) { Slog.w(TAG, "Unknown element under " + tag + ": " + parser.getName() + " at " + mArchiveSourcePath + " " + parser.getPositionDescription()); XmlUtils.skipCurrentTag(parser); continue; } else { outError[0] = "Bad element under " + tag + ": " + parser.getName(); return false; } } } return true; }
Example 14
Source File: XmlUtils.java From android-job with Apache License 2.0 | 5 votes |
public static void skipCurrentTag(XmlPullParser parser) throws XmlPullParserException, IOException { int outerDepth = parser.getDepth(); int type; while ((type=parser.next()) != XmlPullParser.END_DOCUMENT && (type != XmlPullParser.END_TAG || parser.getDepth() > outerDepth)) { } }
Example 15
Source File: XmlParserBase.java From org.hl7.fhir.core with Apache License 2.0 | 4 votes |
protected void skipEmptyElement(XmlPullParser xpp) throws XmlPullParserException, IOException { while (xpp.getEventType() != XmlPullParser.END_TAG) next(xpp); next(xpp); }
Example 16
Source File: EmojiParser.java From emoji with Apache License 2.0 | 4 votes |
public void readMap(Context mContext) { if (convertMap == null || convertMap.size() == 0) { convertMap = new HashMap<List<Integer>, String>(); XmlPullParser xmlpull = null; String fromAttr = null; String key = null; ArrayList<String> emos = null; try { XmlPullParserFactory xppf = XmlPullParserFactory.newInstance(); xmlpull = xppf.newPullParser(); InputStream stream = mContext.getAssets().open("emoji.xml"); xmlpull.setInput(stream, "UTF-8"); int eventCode = xmlpull.getEventType(); while (eventCode != XmlPullParser.END_DOCUMENT) { switch (eventCode) { case XmlPullParser.START_DOCUMENT: { break; } case XmlPullParser.START_TAG: { if (xmlpull.getName().equals("key")) { emos = new ArrayList<String>(); key = xmlpull.nextText(); } if (xmlpull.getName().equals("e")) { fromAttr = xmlpull.nextText(); emos.add(fromAttr); List<Integer> fromCodePoints = new ArrayList<Integer>(); if (fromAttr.length() > 6) { String[] froms = fromAttr.split("\\_"); for (String part : froms) { fromCodePoints.add(Integer.parseInt(part, 16)); } } else { fromCodePoints.add(Integer.parseInt(fromAttr, 16)); } convertMap.put(fromCodePoints, fromAttr); } break; } case XmlPullParser.END_TAG: { if (xmlpull.getName().equals("dict")) { emoMap.put(key, emos); } break; } case XmlPullParser.END_DOCUMENT: { Trace.d("parse emoji complete"); break; } } eventCode = xmlpull.next(); } } catch (Exception e) { e.printStackTrace(); } } }
Example 17
Source File: XmlParser.java From SimpleNews with Apache License 2.0 | 4 votes |
/** * Parse changeLogVersion node * * @param parser * @param news * @throws Exception */ private static void readCategory(XmlPullParser parser, News news) throws XmlPullParserException, IOException { if (parser == null) return; parser.require(XmlPullParser.START_TAG, null, TAG_CATEGORY); // Read attributes String categoryName = parser.getAttributeValue(null, ATTRIBUTE_NAME); String color = parser.getAttributeValue(null, ATTRIBUTE_COLOR); String visible = parser.getAttributeValue(null, ATTRIBUTE_VISIBLE); Category category = new Category(); try { category.setColorId(Color.parseColor(color)); } catch (IllegalArgumentException e) { // Unknown color, try to parse it as integer try { category.setColorId(Integer.parseInt(color)); } catch (NumberFormatException ne) { // not a number, set default value category.setColorId(0); } } category.setName(categoryName); if (visible != null) { category.setVisible(!"false".equals(visible)); } // Parse nested nodes while (parser.next() != XmlPullParser.END_TAG) { if (parser.getEventType() != XmlPullParser.START_TAG) { continue; } String tag = parser.getName(); Log.d(TAG, "Processing tag=" + tag); if (tag.equals(TAG_FEED)) { Feed feed = readFeed(parser); if (feed != null) { category.getFeeds().add(feed); } } } news.getCategories().add(category); }
Example 18
Source File: KeyChainSnapshotDeserializer.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
private static KeyDerivationParams readKeyDerivationParams(XmlPullParser parser) throws XmlPullParserException, IOException, KeyChainSnapshotParserException { parser.require(XmlPullParser.START_TAG, NAMESPACE, TAG_KEY_DERIVATION_PARAMS); int memoryDifficulty = -1; int algorithm = -1; byte[] salt = null; while (parser.next() != XmlPullParser.END_TAG) { if (parser.getEventType() != XmlPullParser.START_TAG) { continue; } String name = parser.getName(); switch (name) { case TAG_MEMORY_DIFFICULTY: memoryDifficulty = readIntTag(parser, TAG_MEMORY_DIFFICULTY); break; case TAG_ALGORITHM: algorithm = readIntTag(parser, TAG_ALGORITHM); break; case TAG_SALT: salt = readBlobTag(parser, TAG_SALT); break; default: throw new KeyChainSnapshotParserException( String.format( Locale.US, "Unexpected tag %s in keyDerivationParams", name)); } } if (salt == null) { throw new KeyChainSnapshotParserException("salt was not set in keyDerivationParams"); } KeyDerivationParams keyDerivationParams = null; switch (algorithm) { case KeyDerivationParams.ALGORITHM_SHA256: keyDerivationParams = KeyDerivationParams.createSha256Params(salt); break; case KeyDerivationParams.ALGORITHM_SCRYPT: keyDerivationParams = KeyDerivationParams.createScryptParams( salt, memoryDifficulty); break; default: throw new KeyChainSnapshotParserException( "Unknown algorithm in keyDerivationParams"); } parser.require(XmlPullParser.END_TAG, NAMESPACE, TAG_KEY_DERIVATION_PARAMS); return keyDerivationParams; }
Example 19
Source File: XMLParser.java From light-novel-library_Wenku8_Android with GNU General Public License v2.0 | 4 votes |
static public NovelIntro getNovelIntro(String xml) { try { XmlPullParserFactory factory = XmlPullParserFactory.newInstance(); XmlPullParser xmlPullParser = factory.newPullParser(); NovelIntro ni = null; xmlPullParser.setInput(new StringReader(xml)); int eventType = xmlPullParser.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { switch (eventType) { case XmlPullParser.START_DOCUMENT:// all start break; case XmlPullParser.START_TAG: if ("metadata".equals(xmlPullParser.getName())) { ni = new NovelIntro(); // Log.v("MewX-XML", "aid=" + n.aid); } else if ("data".equals(xmlPullParser.getName())) { if ("Title".equals(xmlPullParser.getAttributeValue(0))) { ni.aid = new Integer( xmlPullParser.getAttributeValue(1)); ni.title = xmlPullParser.nextText(); } else if ("Author".equals(xmlPullParser .getAttributeValue(0))) { ni.author = xmlPullParser.getAttributeValue(1); } else if ("BookStatus".equals(xmlPullParser .getAttributeValue(0))) { ni.status = new Integer( xmlPullParser.getAttributeValue(1)); // Log.v("MewX-XML", "push=" + n.push); } else if ("LastUpdate".equals(xmlPullParser .getAttributeValue(0))) { ni.update = xmlPullParser.getAttributeValue(1); // Log.v("MewX-XML", "fav=" + n.fav); } else if ("IntroPreview".equals(xmlPullParser .getAttributeValue(0))) { ni.intro_short = xmlPullParser.nextText(); // Log.v("MewX-XML", "fav=" + n.fav); } } break; case XmlPullParser.END_TAG: if ("metadata".equals(xmlPullParser.getName())) { // nothing } break; } eventType = xmlPullParser.next(); } return ni; } catch (Exception e) { e.printStackTrace(); return null; } }
Example 20
Source File: Dsmlv2ResponseParser.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * Launches the parsing of the Batch Response only * * @throws XmlPullParserException if an error occurs in the parser */ public void parseBatchResponse() throws XmlPullParserException { XmlPullParser xpp = container.getParser(); int eventType = xpp.getEventType(); do { switch ( eventType ) { case XmlPullParser.START_DOCUMENT : container.setState( Dsmlv2StatesEnum.INIT_GRAMMAR_STATE ); break; case XmlPullParser.END_DOCUMENT : container.setState( Dsmlv2StatesEnum.GRAMMAR_END ); break; case XmlPullParser.START_TAG : processTag( container, Tag.START ); break; case XmlPullParser.END_TAG : processTag( container, Tag.END ); break; default: break; } try { eventType = xpp.next(); } catch ( IOException ioe ) { throw new XmlPullParserException( I18n.err( I18n.ERR_03019_IO_EXCEPTION_OCCURED, ioe.getLocalizedMessage() ), xpp, ioe ); } } while ( container.getState() != Dsmlv2StatesEnum.BATCH_RESPONSE_LOOP ); }