Android Web request content format
I want to format the content I get from a specific website to show it on my device . For example , from this page I need only the program titles and the description of each one . I get the html code for this page with this function :
private String getPage() {
String str = "***";
try
{
HttpClient hc = new DefaultHttpClient();
HttpPost post = new HttpPos开发者_C百科t("http://golfnews.no/golfpaatv.php");
HttpResponse rp = hc.execute(post);
if(rp.getStatusLine().getStatusCode() == HttpStatus.SC_OK)
{
str = EntityUtils.toString(rp.getEntity());
}
}catch(IOException e){
e.printStackTrace();
}
return str;
}
It returns a string which contains the html code. Now I want to have some strings containing the titles and other strings containing the description . I tried a few methods but I can't figure out what to do ! I am a beginner and I don't know much in android . Could you please help me ? Thanks.
Instead of that URL, you just fetch RSS by using this link, and now parse the RSS either by using SAX Parser, DOM Parser or Pull Parser.
精彩评论