Here you can find the source of readBool(XmlPullParser parser, String tagName)
Parameter | Description |
---|---|
parser | The parser to read the boolean from |
tagName | the name of the tag that contains the boolean |
public static boolean readBool(XmlPullParser parser, String tagName) throws IOException, XmlPullParserException
//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.j a v a 2 s. c om*/ * Reads boolean from the next xml tag * * @param parser The parser to read the boolean from * @param tagName the name of the tag that contains the boolean */ public static boolean readBool(XmlPullParser parser, String tagName) throws IOException, XmlPullParserException { return readText(parser, tagName).equals("true"); } /** * 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; } }