List of utility methods to do XmlPullParser Read
int | readInt(XmlPullParser parser) read Int String result = ""; if (parser.next() == XmlPullParser.TEXT) { result = parser.getText(); parser.nextTag(); return Integer.parseInt(result); |
int | readIntAttribute(XmlPullParser in, String name) read Int Attribute final String value = in.getAttributeValue(null, name); try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new ProtocolException("problem parsing " + name + "=" + value + " as int"); |
int | readIntAttribute(XmlPullParser in, String name) read Int Attribute final String value = in.getAttributeValue(null, name); try { return Integer.parseInt(value); } catch (NumberFormatException e) { throw new ProtocolException("problem parsing " + name + "=" + value + " as int"); |
int | readIntAttribute(XmlPullParser in, String name, int defaultValue) read Int Attribute final String value = in.getAttributeValue(null, name); try { return Integer.parseInt(value); } catch (NumberFormatException e) { return defaultValue; |
int | readInteger(XmlPullParser parser, String ns, String tag) read Integer parser.require(XmlPullParser.START_TAG, ns, tag); int integer = readInt(parser); parser.require(XmlPullParser.END_TAG, ns, tag); return integer; |
long | readLongAttribute(XmlPullParser in, String name) read Long Attribute final String value = in.getAttributeValue(null, name); try { return Long.parseLong(value); } catch (NumberFormatException e) { throw new ProtocolException("problem parsing " + name + "=" + value + " as long"); |
long | readLongAttribute(XmlPullParser in, String name, long defaultValue) read Long Attribute final String value = in.getAttributeValue(null, name); try { return Long.parseLong(value); } catch (NumberFormatException e) { return defaultValue; |
int | readNumber(XmlPullParser parser) read Number try { String text = readText(parser); return Integer.parseInt(text); } catch (NumberFormatException ex) { throw new XmlPullParserException("Expected number"); |
String | readString(XmlPullParser parser, String ns, String tag) read String parser.require(XmlPullParser.START_TAG, ns, tag);
String string = readText(parser);
parser.require(XmlPullParser.END_TAG, ns, tag);
return string;
|
String[] | readStringArray(XmlPullParser parser, String tagName, String delimiter) Reads a String[] from the next xml tag parser.require(XmlPullParser.START_TAG, NAMESPACE, tagName); String[] values = new String[0]; if (parser.next() == XmlPullParser.TEXT) { String text = parser.getText(); values = text.split(delimiter); parser.next(); parser.require(XmlPullParser.END_TAG, NAMESPACE, tagName); ... |