Code example for XmlPullParser

Methods: getAttributeName, getAttributeValue, getName, getText, next, setFeature, setInput

0
        assertEquals("true", parser.getAttributeValue(0));
    } 
 
    public void testUnterminatedEntityWithRelaxed() throws Exception { 
        XmlPullParser parser = newPullParser();
        parser.setFeature("http://xmlpull.org/v1/doc/features.html#relaxed", true);
        parser.setInput(new StringReader("<foo bar='A&W'>mac&cheese</foo>"));
        assertEquals(XmlPullParser.START_TAG, parser.next());
        assertEquals("foo", parser.getName());
        assertEquals("bar", parser.getAttributeName(0));
        assertEquals("A&W", parser.getAttributeValue(0));
        assertEquals(XmlPullParser.TEXT, parser.next());
        assertEquals("mac&cheese", parser.getText());
    } 
 
    public void testEntitiesAndNamespaces() throws Exception { 
        XmlPullParser parser = newPullParser();
        parser.setFeature("http://xmlpull.org/v1/doc/features.html#process-namespaces", true);
        parser.setInput(new StringReader(
                "<foo:a xmlns:foo='http://foo' xmlns:bar='http://bar'><bar:b/></foo:a>")); 
        testNamespace(parser);