Android XmlPullParser Value Get getAttributeByName(XmlPullParser xpp, String name)

Here you can find the source of getAttributeByName(XmlPullParser xpp, String name)

Description

Returns the XML attribute by name, not as fast as using attribute indexes but much more durable in case of future api changes

Parameter

Parameter Description
xpp a parameter
name a parameter

Declaration

public static String getAttributeByName(XmlPullParser xpp, String name) 

Method Source Code

//package com.java2s;
import org.xmlpull.v1.XmlPullParser;

public class Main {
    /**//  w w w . j  a  v  a2 s .c o m
     * Returns the XML attribute by name, not as fast as using attribute indexes
     * but much more durable in case of future api changes
     * 
     * @param xpp
     * @param name
     * @return
     */
    public static String getAttributeByName(XmlPullParser xpp, String name) {
        for (int i = 0; i < xpp.getAttributeCount(); i++)
            if (name.equalsIgnoreCase(xpp.getAttributeName(i)))
                return xpp.getAttributeValue(i);

        return null;
    }
}

Related

  1. getAttributeValue(XmlPullParser pp, String name)
  2. getAttributeValue(XmlPullParser pp, String name)
  3. getAttributes( XmlPullParser pullParser)
  4. getAttributes( XmlPullParser pullParser, String namespace, String elementName, String attributeName, String attributeValue)