Android Utililty Methods XmlPullParser Value Get

List of utility methods to do XmlPullParser Value Get

Description

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

Method

StringgetRequiredAttributeValue(XmlPullParser pp, String namespace, String name)
Read attribute value and return it or throw exception if current element does not have such attribute.
String value = pp.getAttributeValue(namespace, name);
if (value == null) {
    throw new XmlPullParserException("required attribute " + name
            + " is not present");
} else {
    return value;
HashMapgetValuesMap(XmlPullParser parser)
get Values Map
HashMap<String, String> map = new HashMap<String, String>();
int length = parser.getAttributeCount();
for (int i = 0; i < length; i++) {
    map.put(parser.getAttributeName(i), parser.getAttributeValue(i));
return map;
float[]loadFloatArrayByParser(XmlPullParser parser)
load Float Array By Parser
String line;
try {
    line = parser.nextText();
    line = line.trim();
    line = line.replace("\\r\\n", " ");
    line = line.replace("\n", " ");
    String[] szStrings = line.split("[ ]+");
    int length = szStrings.length;
...
floatloadFloatByParser(XmlPullParser parser)
load Float By Parser
String line;
try {
    line = parser.nextText();
    line = line.trim();
    return Float.parseFloat(line);
} catch (XmlPullParserException e) {
    e.printStackTrace();
} catch (IOException e) {
...
int[]loadIntArrayByParser(XmlPullParser parser)
load Int Array By Parser
String line;
try {
    line = parser.nextText();
    line = line.trim();
    line = line.replace("\\r\\n", " ");
    line = line.replace("\n", " ");
    String[] szStrings = line.split("[ ]+");
    int length = szStrings.length;
...
String[]loadStringArrayByParser(XmlPullParser parser)
load String Array By Parser
String line;
try {
    line = parser.nextText();
    line = line.trim();
    line = line.replace("\\r\\n", " ");
    line = line.replace("\n", " ");
    String[] szStrings = line.split("[ ]+");
    return szStrings;
...
StringGetFullName(XmlPullParser reader)
Get Full Name
if (reader.getPrefix() != null)
    return reader.getPrefix() + ":" + reader.getName();
return reader.getName();
StringextractChildText(XmlPullParser paramXmlPullParser)
extract Child Text
if (paramXmlPullParser.next() != 4)
    return null;
return paramXmlPullParser.getText();
StringextractFirstChildTextIgnoreRest( XmlPullParser paramXmlPullParser)
extract First Child Text Ignore Rest
int i = paramXmlPullParser.getDepth();
int j = paramXmlPullParser.next();
String str = null;
if (j != 1) {
    int k = paramXmlPullParser.getDepth();
    if (j == 4)
        if (str == null)
            str = paramXmlPullParser.getText();
...
StringoptAttr(final XmlPullParser pp, final String attrName, final String defaultValue)
opt Attr
final String attr = pp.getAttributeValue(null, attrName);
if (attr != null) {
    final String trimmedAttr = attr.trim();
    if (trimmedAttr.length() > 0)
        return trimmedAttr;
return defaultValue;