Android : How to Parse HTML tags and retrieve information from an HTML page
I'm trying to get live cricket scores from a cricket site. Part of the HTML source is as follows.
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:fb="http://www.facebook.com/2008/fbml" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://developers.facebook.com/schema/">
<head>
<meta name="google-site-verification" content="ZxdgH3XglRg0Bsy-Ho2RnO3EE4nRs53FloLS6fkt_nc" />
<title>Eng 132/4 (29.3 ov, MJ Prior 27*, IJL Trott 53*, JM Davison 0/10) | Live Scorecard | ESPN Cricinfo</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="keywords" content="Canada v England, Live cricket score, Khan Shaheb Osman Ali Stadium, Fatullah, Fatullah, Other one-day/limited-overs matches" />
<meta name="description" content="Live cricket score and commentary for ICC World Cup Warm-up Matches, Canada v England at Fatullah, Feb 16, 2011" />
My point of interest is the <title>
tag. How do I parse through the file and retrieve
info on the title tag?
P.S. I get the above HTML link from an XML file. Am planning to use the code in the following link to parse through the XML file and retrieve the T
http://ww开发者_如何学Cw.ibm.com/developerworks/opensource/library/x-android/
Regards, Sam
You can open an stream to read through the contents of the URL, and then extract words between <title>
and </title>
tags with the help of String.substring()
and String.indeOf()
methods (The dirty way). or follow what this link says (regex)
精彩评论