Android XmlPullParser Read readText(XmlPullParser parser, String tagName)

Here you can find the source of readText(XmlPullParser parser, String tagName)

Description

Reads a String from the next xml tag

Parameter

Parameter Description
parser The parser to read the String from
tagName the name of the tag that contains the String

Declaration

public static String readText(XmlPullParser parser, String tagName)
        throws XmlPullParserException, IOException 

Method Source Code

//package com.java2s;

import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;

import java.io.IOException;

public class Main {
    public static final String NAMESPACE = null;

    /**/*from   w w w.  ja  v a 2  s . co m*/
     * Reads a String from the next xml tag
     *
     * @param parser  The parser to read the String from
     * @param tagName the name of the tag that contains the String
     */
    public static String readText(XmlPullParser parser, String tagName)
            throws XmlPullParserException, IOException {

        String result = "";
        parser.require(XmlPullParser.START_TAG, NAMESPACE, tagName);
        if (parser.next() == XmlPullParser.TEXT) {
            result = parser.getText();
            parser.nextTag();
        }
        parser.require(XmlPullParser.END_TAG, NAMESPACE, tagName);
        return result;
    }
}

Related

  1. readStringAttribute(XmlPullParser in, String name)
  2. readText(XmlPullParser parser)
  3. readText(XmlPullParser parser)
  4. readText(XmlPullParser parser)
  5. readText(XmlPullParser parser)
  6. readThisDoubleArrayXml( XmlPullParser parser, String endTag, String[] name)
  7. readThisDoubleArrayXml(XmlPullParser parser, String endTag, String[] name)
  8. readThisIntArrayXml(XmlPullParser parser, String endTag, String[] name)
  9. readThisIntArrayXml(XmlPullParser parser, String endTag, String[] name)