Code example for XmlPullParser

Methods: getAttributeCount, getAttributeName, getAttributeValue, nextToken, setInput

0
                + "would resolve these to the empty string.", "&aaa;", parser.getAttributeValue(0));
    } 
 
    public void testMissingEntitiesInAttributesUsingNextToken() throws Exception { 
        XmlPullParser parser = newPullParser();
        parser.setInput(new StringReader("<foo b='&aaa;'></foo>"));
        testMissingEntitiesInAttributesUsingNextToken(parser);
    } 
 
    public void testMissingEntitiesInAttributesUsingNextTokenWithRelaxed() throws Exception { 
        XmlPullParser parser = newPullParser();
        parser.setInput(new StringReader("<foo b='&aaa;'></foo>"));
        parser.setFeature("http://xmlpull.org/v1/doc/features.html#relaxed", true);
        testMissingEntitiesInAttributesUsingNextToken(parser);
    } 
 
    private void testMissingEntitiesInAttributesUsingNextToken(XmlPullParser parser)
            throws Exception { 
        assertEquals(XmlPullParser.START_TAG, parser.nextToken());
        assertEquals(1, parser.getAttributeCount());
        assertEquals("b", parser.getAttributeName(0));
        assertEquals("Expected unresolved entities to be left in-place. The old parser "
                + "would resolve these to the empty string.", "&aaa;", parser.getAttributeValue(0));
    } 
 
    public void testGreaterThanInText() throws Exception { 
        XmlPullParser parser = newPullParser();
        parser.setInput(new StringReader("<foo>></foo>"));