Code example for XmlPullParser

Methods: getEventType, getName

0
 
private static ElementType getTag(XmlPullParser parser)
throws XmlPullParserException, IOException{ 
ElementType type = ElementType.NO_TYPE;
 
int eventType = parser.getEventType();
if(eventType == XmlPullParser.START_DOCUMENT){
}else if(eventType == XmlPullParser.END_DOCUMENT){
}else if(eventType == XmlPullParser.START_TAG &&
		parser.getName() == "category"){
	type = ElementType.CATEGORY_START;
}else if(eventType == XmlPullParser.END_TAG &&
		parser.getName() == "category"){
	type = ElementType.CATEGORY_END;
}else if(eventType == XmlPullParser.START_TAG &&
		parser.getName() == "package"){
	type = ElementType.PACKAGE_START;
}else if(eventType == XmlPullParser.END_TAG &&
		parser.getName() == "package"){
	type = ElementType.PACKAGE_END;
} 
return type;
}