Here you can find the source of readStringArray(XmlPullParser parser, String tagName, String delimiter)
Parameter | Description |
---|---|
parser | The parser to read the String from |
tagName | the name of the tag that contains the String Array |
delimiter | Regular expression delimiter for the text to create the String Array |
Parameter | Description |
---|---|
IOException | an exception |
XmlPullParserException | an exception |
public static String[] readStringArray(XmlPullParser parser, String tagName, String delimiter) 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; /**/* w w w . ja v a2s . c om*/ * 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 Array * @param delimiter Regular expression delimiter for the text to create the String Array * @throws IOException * @throws XmlPullParserException */ public static String[] readStringArray(XmlPullParser parser, String tagName, String delimiter) throws IOException, XmlPullParserException { parser.require(XmlPullParser.START_TAG, NAMESPACE, tagName); String[] values = new String[0]; if (parser.next() == XmlPullParser.TEXT) { String text = parser.getText(); values = text.split(delimiter); parser.next(); } parser.require(XmlPullParser.END_TAG, NAMESPACE, tagName); return values; } }