Code example for XmlPullParser

Methods: getName, getPositionDescription, next

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