Code example for XmlPullParser

Methods: defineEntityReplacementText, getAttributeValue, getText, next, setInput

0
        assertParseFailure("<?xml version='1.0' encoding='UTF-8' standalone='no' a='b'?><foo/>"); 
    } 
 
    public void testCustomEntitiesUsingNext() throws Exception { 
        XmlPullParser parser = newPullParser();
        parser.setInput(new StringReader(
                "<foo a='cd&aaaaaaaaaa;ef'>wx&aaaaaaaaaa;yz</foo>")); 
        parser.defineEntityReplacementText("aaaaaaaaaa", "b");
        assertEquals(XmlPullParser.START_TAG, parser.next());
        assertEquals("cdbef", parser.getAttributeValue(0));
        assertEquals(XmlPullParser.TEXT, parser.next());
        assertEquals("wxbyz", parser.getText());
    } 
 
    public void testCustomEntitiesUsingNextToken() throws Exception { 
        XmlPullParser parser = newPullParser();
        parser.setInput(new StringReader(
                "<foo a='cd&aaaaaaaaaa;ef'>wx&aaaaaaaaaa;yz</foo>")); 
        parser.defineEntityReplacementText("aaaaaaaaaa", "b");
        assertEquals(XmlPullParser.START_TAG, parser.nextToken());
        assertEquals("cdbef", parser.getAttributeValue(0));