Code example for XmlPullParser

Methods: getText, next, nextTag, require

0
		} 
		return new Show(id,showName,description,inicio,fim);
	} 
 
	private Time readTime(XmlPullParser parser,String key) throws XmlPullParserException, IOException {
		parser.require(XmlPullParser.START_TAG, null, key);
		String time = readText(parser);
		parser.require(XmlPullParser.END_TAG, null, key);
		return parseTime(time);
	} 
	 
	private Time parseTime(String time) {
		StringTokenizer st = new StringTokenizer(time," ");
		String data = st.nextToken();
		String hours = st.nextToken();
		st = new StringTokenizer(data,"-");
		int year = Integer.parseInt(st.nextToken());
		int month = Integer.parseInt(st.nextToken()) - 1;
		int day = Integer.parseInt(st.nextToken());
		st = new StringTokenizer(hours,":");
		int hour = Integer.parseInt(st.nextToken());
		int minute = Integer.parseInt(st.nextToken());
		 
		Time t = new Time();
		t.set(0, minute, hour, day, month, year);
		return t;
	} 
 
	private String readDescription(XmlPullParser parser) throws XmlPullParserException, IOException {
		parser.require(XmlPullParser.START_TAG, null, KEY_DESCRIPTION);
		String description = readText(parser);
		parser.require(XmlPullParser.END_TAG, null, KEY_DESCRIPTION);
		return description;
	} 
 
	private String readName(XmlPullParser parser) throws XmlPullParserException, IOException {
		parser.require(XmlPullParser.START_TAG, null, KEY_NAME);
		String name = readText(parser);
		parser.require(XmlPullParser.END_TAG, null, KEY_NAME);
		return name;
	} 
 
	private int readId(XmlPullParser parser) throws XmlPullParserException, IOException {
		parser.require(XmlPullParser.START_TAG, null, KEY_ID);
		String id = readText(parser);
		parser.require(XmlPullParser.END_TAG, null, KEY_ID);
		return Integer.parseInt(id);
	} 
 
	private String readText(XmlPullParser parser) throws XmlPullParserException, IOException{
		String result = "";
		if(parser.next() == XmlPullParser.TEXT){
			result = parser.getText();
			parser.nextTag();
		} 
		return result;
	} 
	 
	private void skip(XmlPullParser parser) throws XmlPullParserException, IOException {