Code example for XmlPullParser

Methods: getInputEncoding, getProperty, nextToken, setInput

0
        assertEquals(XmlPullParser.END_DOCUMENT, parser.next());
    } 
 
    public void testXmlDeclaration() throws Exception { 
        XmlPullParser parser = newPullParser();
        parser.setInput(new StringReader(
                "<?xml version='1.0' encoding='UTF-8' standalone='no'?><foo/>")); 
        assertEquals(XmlPullParser.START_TAG, parser.nextToken());
        assertEquals("1.0", parser.getProperty(
                "http://xmlpull.org/v1/doc/properties.html#xmldecl-version")); 
        assertEquals(Boolean.FALSE, parser.getProperty(
                "http://xmlpull.org/v1/doc/properties.html#xmldecl-standalone")); 
        assertEquals("UTF-8", parser.getInputEncoding());
    } 
 
    public void testXmlDeclarationExtraAttributes() throws Exception { 
        assertParseFailure("<?xml version='1.0' encoding='UTF-8' standalone='no' a='b'?><foo/>"); 
    } 
 
    public void testCustomEntitiesUsingNext() throws Exception { 
        XmlPullParser parser = newPullParser();