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.

License

Open Source License

Declaration


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

Method Source Code

//package com.java2s;
// for license please see accompanying LICENSE.txt file (available also at http://www.xmlpull.org/)

import java.io.IOException;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

public class Main {
    /**//  www.j  av a2s .c  o m
     * 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. getPIData(XmlPullParser pp)
  2. getPIData(XmlPullParser pp)
  3. getPITarget(XmlPullParser pp)
  4. getPITarget(XmlPullParser pp)
  5. getRequiredAttributeValue(XmlPullParser pp, String namespace, String name)
  6. getValuesMap(XmlPullParser parser)
  7. loadFloatArrayByParser(XmlPullParser parser)
  8. loadFloatByParser(XmlPullParser parser)
  9. loadIntArrayByParser(XmlPullParser parser)