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

StringreadAttribute(XmlPullParser parser, String tag, String attributeName)
read Attribute
parser.require(XmlPullParser.START_TAG, NULL, tag);
String attributeData = parser
        .getAttributeValue(NULL, attributeName);
parser.nextTag();
parser.require(XmlPullParser.END_TAG, NULL, tag);
return attributeData;
BitmapreadBitmapAttribute(XmlPullParser in, String name)
read Bitmap Attribute
final byte[] value = readByteArrayAttribute(in, name);
if (value != null) {
    return BitmapFactory.decodeByteArray(value, 0, value.length);
} else {
    return null;
BitmapreadBitmapAttribute(XmlPullParser in, String name)
read Bitmap Attribute
final byte[] value = readByteArrayAttribute(in, name);
if (value != null) {
    return BitmapFactory.decodeByteArray(value, 0, value.length);
} else {
    return null;
booleanreadBool(XmlPullParser parser, String tagName)
Reads boolean from the next xml tag
return readText(parser, tagName).equals("true");
booleanreadBooleanAttribute(XmlPullParser in, String name)
read Boolean Attribute
final String value = in.getAttributeValue(null, name);
return Boolean.parseBoolean(value);
booleanreadBooleanAttribute(XmlPullParser in, String name)
read Boolean Attribute
final String value = in.getAttributeValue(null, name);
return Boolean.parseBoolean(value);
booleanreadBooleanAttribute(XmlPullParser in, String name, boolean defaultValue)
read Boolean Attribute
final String value = in.getAttributeValue(null, name);
if (value == null) {
    return defaultValue;
} else {
    return Boolean.parseBoolean(value);
byte[]readByteArrayAttribute(XmlPullParser in, String name)
read Byte Array Attribute
final String value = in.getAttributeValue(null, name);
if (value != null) {
    return Base64.decode(value, Base64.DEFAULT);
} else {
    return null;
DatereadDate(XmlPullParser parser, String tagName, String dateFormat)
Reads a date from the next xml tag
parser.require(XmlPullParser.START_TAG, NAMESPACE, tagName);
Date date = null;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(
        dateFormat, Locale.ENGLISH);
if (parser.next() == XmlPullParser.TEXT) {
    try {
        date = simpleDateFormat.parse(parser.getText());
    } catch (ParseException e) {
...
floatreadFloatAttribute(XmlPullParser in, String name)
read Float Attribute
final String value = in.getAttributeValue(null, name);
try {
    return Float.parseFloat(value);
} catch (NumberFormatException e) {
    throw new ProtocolException("problem parsing " + name + "="
            + value + " as long");