Here you can find the source of readText(XmlPullParser parser, String tagName)
Parameter | Description |
---|---|
parser | The parser to read the String from |
tagName | the name of the tag that contains the String |
public static String readText(XmlPullParser parser, String tagName) throws XmlPullParserException, IOException
//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; } }