Code example for XmlPullParser

Methods: getAttributeCountgetAttributeNamegetAttributeValuegetDepthgetEventTypegetNamegetTextnext

0
        } 
    } 
 
    static void validate(XmlPullParser parser)
            throws XmlPullParserException, IOException { 
        assertEquals(XmlPullParser.START_DOCUMENT, parser.getEventType());
 
        assertEquals(0, parser.getDepth());
 
        assertEquals(XmlPullParser.START_TAG, parser.next());
 
        assertEquals(1, parser.getDepth());
 
        assertEquals("dagny", parser.getName());
        assertEquals(1, parser.getAttributeCount());
        assertEquals("dad", parser.getAttributeName(0));
        assertEquals("bob", parser.getAttributeValue(0));
        assertEquals("bob", parser.getAttributeValue(null, "dad"));
 
        assertEquals(XmlPullParser.TEXT, parser.next());
 
        assertEquals(1, parser.getDepth());
 
        assertEquals("hello", parser.getText());
 
        assertEquals(XmlPullParser.END_TAG, parser.next());
 
        assertEquals(1, parser.getDepth());
 
        assertEquals("dagny", parser.getName());
 
        assertEquals(XmlPullParser.END_DOCUMENT, parser.next());
 
        assertEquals(0, parser.getDepth());
    } 
 
    static final String XML =
        "<one xmlns='ns:default' xmlns:n1='ns:1' a='b'>\n" 
              + "  <n1:two c='d' n1:e='f' xmlns:n2='ns:2'>text</n1:two>\n" 
Connect your IDE to all the code out there  Get Codota for Java