1
我triing解析這個網站:http://www.proyectoglass.com/feeds/posts/default?alt=rss 用下面的代碼:解析博客RSS與Jsoup
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);
}
,然後我得到以下錯誤:
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
,但裏面的標記解析我有文字,任何人都可以幫我看看我做錯了什麼?
非常感謝。