Android Utililty Methods XmlPullParser Read

List of utility methods to do XmlPullParser Read

Description

The list of methods to do XmlPullParser Read are organized into topic(s).

Method

intreadInt(XmlPullParser parser)
read Int
String result = "";
if (parser.next() == XmlPullParser.TEXT) {
    result = parser.getText();
    parser.nextTag();
return Integer.parseInt(result);
intreadIntAttribute(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");
intreadIntAttribute(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");
intreadIntAttribute(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;
intreadInteger(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;
longreadLongAttribute(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");
longreadLongAttribute(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;
intreadNumber(XmlPullParser parser)
read Number
try {
    String text = readText(parser);
    return Integer.parseInt(text);
} catch (NumberFormatException ex) {
    throw new XmlPullParserException("Expected number");
StringreadString(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);
...