Android XmlPullParser Value Get getRequiredAttributeValue(XmlPullParser pp, String namespace, String name)

Here you can find the source of getRequiredAttributeValue(XmlPullParser pp, String namespace, String name)

Description

Read attribute value and return it or throw exception if current element does not have such attribute.

Declaration


public static String getRequiredAttributeValue(XmlPullParser pp,
        String namespace, String name) throws IOException,
        XmlPullParserException 

Method Source Code

//package com.java2s;
import java.io.IOException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

public class Main {
    /**//from   w w  w.ja  va  2s.  com
     * Read attribute value and return it or throw exception if
     * current element does not have such attribute.
     */

    public static String getRequiredAttributeValue(XmlPullParser pp,
            String namespace, String name) throws IOException,
            XmlPullParserException {
        String value = pp.getAttributeValue(namespace, name);
        if (value == null) {
            throw new XmlPullParserException("required attribute " + name
                    + " is not present");
        } else {
            return value;
        }
    }

    /**
     * Return value of attribute with given name and no namespace.
     */
    public static String getAttributeValue(XmlPullParser pp, String name) {
        return pp.getAttributeValue(XmlPullParser.NO_NAMESPACE, name);
    }
}

Related

  1. getAttributes( XmlPullParser pullParser, String namespace, String elementName, String attributeName, String attributeValue)
  2. getPIData(XmlPullParser pp)
  3. getPIData(XmlPullParser pp)
  4. getPITarget(XmlPullParser pp)
  5. getPITarget(XmlPullParser pp)
  6. getRequiredAttributeValue(XmlPullParser pp, String namespace, String name)
  7. getValuesMap(XmlPullParser parser)
  8. loadFloatArrayByParser(XmlPullParser parser)
  9. loadFloatByParser(XmlPullParser parser)