Code example for XmlPullParser

Methods: defineEntityReplacementText, getAttributeValue, getText, next, setInput

0
        assertEquals("yz", parser.getText());
    } 
 
    public void testCustomEntitiesAreNotEvaluated() throws Exception { 
        XmlPullParser parser = newPullParser();
        parser.setInput(new StringReader(
                "<foo a='&a;'>&a;</foo>")); 
        parser.defineEntityReplacementText("a", "&amp; &a;");
        assertEquals(XmlPullParser.START_TAG, parser.next());
        assertEquals("&amp; &a;", parser.getAttributeValue(0));
        assertEquals(XmlPullParser.TEXT, parser.next());
        assertEquals("&amp; &a;", parser.getText());
    } 
 
    public void testMissingEntities() throws Exception { 
        assertParseFailure("<foo>&aaa;</foo>"); 
    } 
 
    public void testMissingEntitiesWithRelaxed() throws Exception { 
        XmlPullParser parser = newPullParser();
        parser.setFeature("http://xmlpull.org/v1/doc/features.html#relaxed", true);