Android XmlPullParser - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android XmlPullParser class.

This code example shows how to use the following methods: getAttributeValue, next, setInput
        assertParseFailure("<foo a='<'></foo>"); 
    } 
 
    public void testQuotesInAttribute() throws Exception{ 
        XmlPullParser parser = newPullParser();
        parser.setInput(new StringReader("<foo a='\"' b=\"'\"></foo>"));
        assertEquals(XmlPullParser.START_TAG, parser.next());
        assertEquals("\"", parser.getAttributeValue(0));
        assertEquals("'", parser.getAttributeValue(1));
    } 
 
    public void testQuotesInText() throws Exception{ 
        XmlPullParser parser = newPullParser();
        parser.setInput(new StringReader("<foo>\" '</foo>"));
        assertEquals(XmlPullParser.START_TAG, parser.next());
        assertEquals(XmlPullParser.TEXT, parser.next());
        assertEquals("\" '", parser.getText());
    } 
 
    public void testCdataDelimiterInAttribute() throws Exception{ 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getName, getText, next, nextToken, setInput
    } 
 
    public void testDoctypeWithNextToken() throws Exception { 
        String xml = "<!DOCTYPE foo [<!ENTITY bb \"bar baz\">]><foo>a&bb;c</foo>";
        XmlPullParser parser = newPullParser(xml);
        assertEquals(XmlPullParser.DOCDECL, parser.nextToken());
        assertEquals(" foo [<!ENTITY bb \"bar baz\">]", parser.getText());
        assertNull(parser.getName());
        assertEquals(XmlPullParser.START_TAG, parser.nextToken());
        assertEquals(XmlPullParser.TEXT, parser.next());
        assertEquals("abar bazc", parser.getText());
        assertEquals(XmlPullParser.END_TAG, parser.next());
        assertEquals(XmlPullParser.END_DOCUMENT, parser.next());
    } 
 
    public void testDoctypeSpansBuffers() throws Exception { 
        char[] doctypeChars = new char[READ_BUFFER_SIZE + 1];
        Arrays.fill(doctypeChars, 'x');
        String doctypeBody = " foo [<!--" + new String(doctypeChars) + "-->]";
        String xml = "<!DOCTYPE" + doctypeBody + "><foo/>";

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getName, getText, next, nextToken, setInput
    } 
 
    public void testStructuredEntityAndNextToken() throws Exception { 
        String xml = "<!DOCTYPE foo [<!ENTITY bb \"<bar>baz<!--quux--></bar>\">]><foo>a&bb;c</foo>";
        XmlPullParser parser = newPullParser(xml);
        assertEquals(XmlPullParser.DOCDECL, parser.nextToken());
        assertEquals(XmlPullParser.START_TAG, parser.nextToken());
        assertEquals("foo", parser.getName());
        assertEquals(XmlPullParser.TEXT, parser.nextToken());
        assertEquals("a", parser.getText());
        assertEquals(XmlPullParser.ENTITY_REF, parser.nextToken());
        assertEquals("bb", parser.getName());
        assertEquals("", parser.getText());
        assertEquals(XmlPullParser.START_TAG, parser.nextToken());
        assertEquals("bar", parser.getName());
        assertEquals(XmlPullParser.TEXT, parser.nextToken());
        assertEquals("baz", parser.getText());
        assertEquals(XmlPullParser.COMMENT, parser.nextToken());
        assertEquals("quux", parser.getText());
        assertEquals(XmlPullParser.END_TAG, parser.nextToken());

8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getAttributeValue
 
		return mMimeTypes;
	} 
	 
	private void addMimeTypeStart() { 
		String extension = mXpp.getAttributeValue(null, ATTR_EXTENSION);
		String mimetype = mXpp.getAttributeValue(null, ATTR_MIMETYPE);
		String icon = mXpp.getAttributeValue(null, ATTR_ICON);
		 
		if(icon != null){
			int id = resources.getIdentifier(icon.substring(1) /* to cut the @ */, null, packagename);
			if(id > 0){
				mMimeTypes.put(extension, mimetype, id);
				return; 
			} 
		} 
		 
		mMimeTypes.put(extension, mimetype);
	} 
	 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getAttributeValue, getName, getText, next, nextTag
     */ 
    private void readChangeLogRowNode(XmlPullParser parser, ChangeLog changeLog,String versionName) throws  Exception{
 
        if (parser==null) return;
 
        parser.require(XmlPullParser.START_TAG, null,TAG_CHANGELOGTEXT);
 
        String tag = parser.getName();
        if (tag.equals(TAG_CHANGELOGTEXT)){
            ChangeLogRow row=new ChangeLogRow();
            row.setVersionName(versionName);
 
            // Read attributes 
            String changeLogTextTitle=parser.getAttributeValue(null,ATTRIBUTE_CHANGETEXTTITLE);
            if (changeLogTextTitle!=null)
                row.setChangeTextTitle(changeLogTextTitle);
 
            // It is possible to force bulleted List 
            String bulletedList = parser.getAttributeValue(null, ATTRIBUTE_BULLETEDLIST);
            if (bulletedList!=null){

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Android XmlPullParser Questions & Answers:

Other Android XmlPullParser Examples

13:	         XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
14:	         factory.setNamespaceAware(true);
15:	         XmlPullParser xpp = factory.newPullParser();
16:	
17:	         xpp.setInput(new StringReader ("<foo>Hello World!</foo>"));

Read More

See Code Examples for Android XmlPullParser Methods: