Android XmlPullParser Value Get optAttr(final XmlPullParser pp, final String attrName, final String defaultValue)

Here you can find the source of optAttr(final XmlPullParser pp, final String attrName, final String defaultValue)

Description

opt Attr

License

Open Source License

Declaration

public static String optAttr(final XmlPullParser pp,
            final String attrName, final String defaultValue) 

Method Source Code

//package com.java2s;
/*/*w ww .  jav a  2 s  . c  om*/
 * For license please see accompanying LICENSE.txt file (available also at http://www.xmlpull.org/).
 * According to www.xmlpull.org, this code is in the public domain.
 */

import org.xmlpull.v1.XmlPullParser;

public class Main {
    public static String optAttr(final XmlPullParser pp,
            final String attrName, final String defaultValue) {
        final String attr = pp.getAttributeValue(null, attrName);

        if (attr != null) {
            final String trimmedAttr = attr.trim();

            if (trimmedAttr.length() > 0)
                return trimmedAttr;
        }

        return defaultValue;
    }
}

Related

  1. loadIntArrayByParser(XmlPullParser parser)
  2. loadStringArrayByParser(XmlPullParser parser)
  3. GetFullName(XmlPullParser reader)
  4. extractChildText(XmlPullParser paramXmlPullParser)
  5. extractFirstChildTextIgnoreRest( XmlPullParser paramXmlPullParser)
  6. optFloatAttr(final XmlPullParser pp, final String attrName, final float defaultValue)
  7. optIntAttr(final XmlPullParser pp, final String attrName, final int defaultValue)
  8. optSkip(final XmlPullParser pp, final String tagName)
  9. attr(final XmlPullParser pp, final String attrName)