Android XmlPullParser Read readAttribute(XmlPullParser parser, String tag, String attributeName)

Here you can find the source of readAttribute(XmlPullParser parser, String tag, String attributeName)

Description

read Attribute

Parameter

Parameter Description
parser a parameter
tag a parameter
attributeName a parameter

Exception

Parameter Description
IOException an exception
XmlPullParserException an exception

Return

String

Declaration

public static String readAttribute(XmlPullParser parser, String tag,
        String attributeName) 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 {
    private static final String NULL = null;

    /**/*  ww w. j  ava2 s. co  m*/
     * 
     * @param parser
     * @param tag
     * @param attributeName
     * @return String
     * @throws IOException
     * @throws XmlPullParserException
     */
    public static String readAttribute(XmlPullParser parser, String tag,
            String attributeName) throws IOException,
            XmlPullParserException {
        parser.require(XmlPullParser.START_TAG, NULL, tag);
        String attributeData = parser
                .getAttributeValue(NULL, attributeName);
        parser.nextTag();
        parser.require(XmlPullParser.END_TAG, NULL, tag);
        return attributeData;
    }
}

Related

  1. readBitmapAttribute(XmlPullParser in, String name)
  2. readBitmapAttribute(XmlPullParser in, String name)
  3. readBool(XmlPullParser parser, String tagName)
  4. readBooleanAttribute(XmlPullParser in, String name)