Code example for XmlPullParser

Methods: getName, getPositionDescription, next

0
    } 
 
    @SuppressWarnings("serial") 
    public static class ParseException extends XmlPullParserException {
        public ParseException(String msg, XmlPullParser parser) {
            super(msg + " at " + parser.getPositionDescription());
        } 
    } 
 
    @SuppressWarnings("serial") 
    public static class IllegalStartTag extends ParseException { 
        public IllegalStartTag(XmlPullParser parser, String parent) {
            super("Illegal start tag " + parser.getName() + " in " + parent, parser);
        } 
    } 
 
    @SuppressWarnings("serial") 
    public static class IllegalEndTag extends ParseException { 
        public IllegalEndTag(XmlPullParser parser, String parent) {
            super("Illegal end tag " + parser.getName() + " in " + parent, parser);
        } 
    } 
 
    @SuppressWarnings("serial") 
    public static class IllegalAttribute extends ParseException { 
        public IllegalAttribute(XmlPullParser parser, String attribute) {
            super("Tag " + parser.getName() + " has illegal attribute " + attribute, parser);
        } 
    } 
 
    @SuppressWarnings("serial") 
    public static class NonEmptyTag extends ParseException{ 
        public NonEmptyTag(String tag, XmlPullParser parser) {
            super(tag + " must be empty tag", parser);
        } 
    } 
 
    public static void checkEndTag(String tag, XmlPullParser parser)
            throws XmlPullParserException, IOException { 
        if (parser.next() == XmlPullParser.END_TAG && tag.equals(parser.getName()))
            return; 
        throw new NonEmptyTag(tag, parser);
    } 
 
    public static void checkAttributeExists(TypedArray attr, int attrId, String attrName,