Trifit
Trifit

Reputation: 122

Parsing a Blogger Rss with Jsoup

I'm triing to parse this website: http://www.proyectoglass.com/feeds/posts/default?alt=rss with the following code:

static final String BLOG_URL = "http://www.proyectoglass.com/feeds/posts/default?alt=rss";
static final String TAG_titular = "rss channel item title";

public ArrayList<String> copia=new ArrayList<String>();

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    try {
        Document doc = Jsoup.connect(BLOG_URL).get();
        Elements links = doc.select(TAG_titular);

        for(Element link:links)
        {
            copia.add(link.text());
        }

        if(copia.size() == 0) {
            copia.add("Empty result");
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        copia.clear();
        copia.add("Exception: " + ex.toString());
    }       
    ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>(this,android.R.layout.simple_list_item_1,copia);
    setListAdapter(arrayAdapter);                   
} 

and then I get the following error:

Exception: org.jsoup.UnsupportedMimeTypeException: Unhandled content Type. Must be text/*, application/xml, or application/xhtml+xml. Mimetype=application/rss+xml; charset=UTF-8, URL=http://www.projectglass.com/feed/posts/default?alt=rss

but inside the tag parsed I have text, anyone can help me see what I'm doing wrong?

Thanks a lot.

Upvotes: 1

Views: 1357

Answers (1)

Dave Newton
Dave Newton

Reputation: 160201

The easiest is to set ignoreContentType(true) on the connection returned by Jsoup.connect.

This forces a parsing attempt as detailed in the docs.

Upvotes: 3

Related Questions