I am making a RSS related app.
I want to be able to download RSS(xml) given only website URL that contains:
link rel="alternate" type="application/rss+xml"
For example, http://www.engaget.com source contains:
<link rel="alternate" type="application/rss+xml" title="Engadget" href="http://www.engadget.com/rss.xml">
I am assuming if I open this site as RSS application,
it will re-direct me to http://www.engadget.com/rss.xml page.
My code to download xml is following:
private boolean downloadXml(String url, String filename) {
try {
URL urlxml = new URL(url);
URLConnection ucon = urlxml.openConnection();
ucon.setConnectTimeout(4000);
ucon.setReadTimeout(4000);
InputStream is = ucon.getInputStream();
BufferedInputStream bis = new BufferedInputStream(is, 128);
FileOutputStream fOut = openFileOutput(filename + ".xml", Context.MODE_WORLD_READABLE | Context.MODE_WORLD_WRITEABLE);
OutputStreamWriter osw = new OutputStreamWriter(fOut);
int current = 0;
while ((current = bis.read()) != -1) {
osw.write((byte) current);
}
osw.flush();
osw.close();
} catch (Exception e) {
return false;
}
return true;
}
without me knowing 'http://www.engadget.com/rss.xml' url, how can I download RSS when I input 'http://www.engadget.com"?