Java Code Examples for org.xmlpull.v1.XmlPullParser#getText()
The following examples show how to use
org.xmlpull.v1.XmlPullParser#getText() .
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: OnvifUtils.java From ONVIF-Java with Apache License 2.0 | 6 votes |
/** * Util method for parsing. * Retrieve the XAddrs from the XmlPullParser given. */ public static String retrieveXAddrs(XmlPullParser xpp) throws IOException, XmlPullParserException { String result = ""; int eventType = xpp.getEventType(); while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG && xpp.getName().equals("XAddrs")) { xpp.next(); result = xpp.getText(); break; } eventType = xpp.next(); } return result; }
Example 2
Source File: XmlUtils.java From MyBookshelf with GNU General Public License v3.0 | 6 votes |
/** * Read a flattened object from an XmlPullParser. The XML data could * previously have been written with writeMapXml(), writeListXml(), or * writeValueXml(). The XmlPullParser must be positioned <em>at</em> the * tag that defines the value. * * @param parser The XmlPullParser from which to read the object. * @param name An array of one string, used to return the name attribute * of the value's tag. * @return Object The newly generated value object. * @see #readMapXml * @see #readListXml * @see #writeValueXml */ public static Object readValueXml(XmlPullParser parser, String[] name) throws XmlPullParserException, java.io.IOException { int eventType = parser.getEventType(); do { if (eventType == parser.START_TAG) { return readThisValueXml(parser, name, null); } else if (eventType == parser.END_TAG) { throw new XmlPullParserException( "Unexpected end tag at: " + parser.getName()); } else if (eventType == parser.TEXT) { throw new XmlPullParserException( "Unexpected text: " + parser.getText()); } eventType = parser.next(); } while (eventType != parser.END_DOCUMENT); throw new XmlPullParserException( "Unexpected end of document"); }
Example 3
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 4
Source File: XMLParser.java From mConference-Framework with BSD 3-Clause "New" or "Revised" License | 5 votes |
private static String readText(XmlPullParser parser) throws XmlPullParserException, IOException { String result = ""; if(parser.next() == XmlPullParser.TEXT) { result = parser.getText(); parser.nextTag(); } return result; }
Example 5
Source File: DLNANotifyParser.java From Connect-SDK-Android-Core with Apache License 2.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 6
Source File: FeedParser.java From android-BasicSyncAdapter with Apache License 2.0 | 5 votes |
/** * For the tags title and summary, extracts their text values. */ private String readText(XmlPullParser parser) throws IOException, XmlPullParserException { String result = null; if (parser.next() == XmlPullParser.TEXT) { result = parser.getText(); parser.nextTag(); } return result; }
Example 7
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 8
Source File: firmwareEntriesParser.java From SensorTag-CC2650 with Apache License 2.0 | 5 votes |
private String readTag(XmlPullParser parser,String tag) throws XmlPullParserException, IOException { parser.require(XmlPullParser.START_TAG, ns, tag); String wS = ""; if (parser.next() == XmlPullParser.TEXT) { wS = parser.getText(); parser.nextTag(); } parser.require(XmlPullParser.END_TAG, ns, tag); return wS; }
Example 9
Source File: KmlParser.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 10
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 11
Source File: OutOfBandData.java From Yahala-Messenger with MIT License | 5 votes |
@Override public Element parse(XmlPullParser parser, int initialDepth) throws XmlPullParserException, IOException, SmackException { String url = null, mime = null; long length = -1; boolean in_url = false, done = false; while (!done) { int eventType = parser.next(); if (eventType == XmlPullParser.START_TAG) { if ("url".equals(parser.getName())) { in_url = true; mime = parser.getAttributeValue(null, "type"); String _length = parser.getAttributeValue(null, "length"); try { length = Long.parseLong(_length); } catch (Exception e) { // ignored } } } else if (eventType == XmlPullParser.END_TAG) { if ("url".equals(parser.getName())) { done = true; } } else if (eventType == XmlPullParser.TEXT && in_url) { url = parser.getText(); } } if (url != null) return new OutOfBandData(url, mime, length); else return null; }
Example 12
Source File: PreferenceParser.java From Aegis with GNU General Public License v3.0 | 5 votes |
private static String parseText(XmlPullParser parser) throws IOException, XmlPullParserException { String text = ""; if (parser.next() == XmlPullParser.TEXT) { text = parser.getText(); parser.nextTag(); } return text; }
Example 13
Source File: EmoticonFileUtils.java From imsdk-android with MIT License | 5 votes |
private String readFileName(XmlPullParser parser) throws IOException, XmlPullParserException { parser.require(XmlPullParser.START_TAG,ns,"FILE_FIXED"); String result = ""; if(parser.next()== XmlPullParser.TEXT) { result = parser.getText(); parser.nextTag(); } parser.require(XmlPullParser.END_TAG,ns,"FILE_FIXED"); return result; }
Example 14
Source File: DeviceManager.java From timelapse-sony 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 15
Source File: NoticesXmlParser.java From LicensesDialog with Apache License 2.0 | 5 votes |
private static String readText(final XmlPullParser parser) throws IOException, XmlPullParserException { String result = ""; if (parser.next() == XmlPullParser.TEXT) { result = parser.getText(); parser.nextTag(); } return result; }
Example 16
Source File: RoutesParser.java From VolleyBall with MIT License | 5 votes |
private static Route parse(XmlPullParser aXpp) throws Exception { // Will begin at a START_TAG event type int eventType = aXpp.getEventType(); if (eventType != XmlPullParser.START_TAG) { throw new RuntimeException("Not at correct parse position in routes file"); } Route.Builder builder = new Route.Builder(); String type = aXpp.getAttributeValue(null, "type"); if (type == null) type = "get"; builder.type(type); String path = aXpp.getAttributeValue(null, "path"); if (path == null) { throw new RuntimeException("route tag must contain a path"); } builder.route(path); eventType = aXpp.next(); if (eventType != XmlPullParser.TEXT) { throw new RuntimeException("Not at correct parse position in routes file"); } String value = aXpp.getText(); builder.response(value); // Should verify aParser.next() event is END_TAG eventType = aXpp.next(); if (eventType != XmlPullParser.END_TAG) { throw new RuntimeException("Not at correct parse position in routes file"); } return builder.build(); }
Example 17
Source File: LocaleController.java From Yahala-Messenger with MIT License | 4 votes |
private HashMap<String, String> getLocaleFileStrings(File file) { try { HashMap<String, String> stringMap = new HashMap<String, String>(); XmlPullParser parser = Xml.newPullParser(); parser.setInput(new FileInputStream(file), "UTF-8"); int eventType = parser.getEventType(); String name = null; String value = null; String attrName = null; while (eventType != XmlPullParser.END_DOCUMENT) { if (eventType == XmlPullParser.START_TAG) { name = parser.getName(); int c = parser.getAttributeCount(); if (c > 0) { attrName = parser.getAttributeValue(0); } } else if (eventType == XmlPullParser.TEXT) { if (attrName != null) { value = parser.getText(); if (value != null) { value = value.trim(); value = value.replace("\\n", "\n"); value = value.replace("\\", ""); } } } else if (eventType == XmlPullParser.END_TAG) { value = null; attrName = null; name = null; } if (name != null && name.equals("string") && value != null && attrName != null && value.length() != 0 && attrName.length() != 0) { stringMap.put(attrName, value); name = null; value = null; attrName = null; } eventType = parser.next(); } return stringMap; } catch (Exception e) { FileLog.e("yahala", e); } return null; }
Example 18
Source File: XmlParser.java From droidddle with Apache License 2.0 | 4 votes |
/** * Parse changeLogText node * * @param parser * @param changeLog * @throws Exception */ private void readChangeLogRowNode(XmlPullParser parser, ChangeLog changeLog, String versionName, int versionCode) throws Exception { if (parser == null) return; String tag = parser.getName(); ChangeLogRow row = new ChangeLogRow(); row.setVersionName(versionName); row.setVersionCode(versionCode); // Read attributes String changeLogTextTitle = parser.getAttributeValue(null, ATTRIBUTE_CHANGETEXTTITLE); if (changeLogTextTitle != null) row.setChangeTextTitle(changeLogTextTitle); // It is possible to force bulleted List String bulletedList = parser.getAttributeValue(null, ATTRIBUTE_BULLETEDLIST); if (bulletedList != null) { if (bulletedList.equals("true")) { row.setBulletedList(true); } else { row.setBulletedList(false); } } else { row.setBulletedList(super.bulletedList); } // Read text if (parser.next() == XmlPullParser.TEXT) { String changeLogText = parser.getText(); if (changeLogText == null) throw new ChangeLogException("ChangeLogText required in changeLogText node"); row.parseChangeText(changeLogText); row.setType(tag.equalsIgnoreCase(TAG_CHANGELOGBUG) ? ChangeLogRow.BUGFIX : tag.equalsIgnoreCase(TAG_CHANGELOGIMPROVEMENT) ? ChangeLogRow.IMPROVEMENT : ChangeLogRow.DEFAULT); parser.nextTag(); } changeLog.addRow(row); //Log.d(TAG, "Added row:" + row.toString()); }
Example 19
Source File: ReadSoapHeader.java From directory-ldap-api with Apache License 2.0 | 4 votes |
/** * {@inheritDoc} */ @Override public void action( Dsmlv2Container container ) throws XmlPullParserException { try { XmlPullParser xpp = container.getParser(); StringBuilder sb = new StringBuilder(); String startTag = xpp.getText(); sb.append( startTag ); // string '<' and '>' startTag = startTag.substring( 1, startTag.length() - 1 ); int tagType; String endTag = ""; // continue parsing till we get to the end tag of SOAP header // and match the tag values including the namespace while ( !startTag.equals( endTag ) ) { tagType = xpp.next(); endTag = xpp.getText(); sb.append( endTag ); if ( tagType == XmlPullParser.END_TAG ) { // strip '<', '/' and '>' endTag = endTag.substring( 2, endTag.length() - 1 ); } } // change the state to header end container.setState( Dsmlv2StatesEnum.SOAP_HEADER_END_TAG ); } catch ( IOException e ) { e.printStackTrace(); } }
Example 20
Source File: PullReader.java From simplexml with Apache License 2.0 | 2 votes |
/** * Constructor for the <code>Text</code> object. This creates * an event that provides text to the core reader. Text can be * in the form of a CDATA section or a normal text entry. * * @param source this is the node that represents the text value */ public Text(XmlPullParser source){ this.text = source.getText(); this.source = source; }