【问题标题】:Android : How to Parse HTML tags and retrieve information from an HTML pageAndroid:如何解析 HTML 标记并从 HTML 页面检索信息
【发布时间】:2011-02-16 16:01:43
【问题描述】:

我正在尝试从板球网站获取实时板球比分。 部分HTML源码如下。

<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" />

我的兴趣点是&lt;title&gt; 标签。如何解析文件并检索 标题标签上的信息?

附:我从一个 XML 文件中获得了上面的 HTML 链接。 我打算使用以下链接中的代码来解析 XML 文件 并检索 T

http://www.ibm.com/developerworks/opensource/library/x-android/

问候, 山姆

【问题讨论】:

    标签: android html xml parsing rss


    【解决方案1】:

    您可以打开一个流来读取 URL 的内容,然后在 String.substring() 和 String.indeOf() 方法的帮助下提取 &lt;title&gt; 和 &lt;/title&gt; 标签之间的单词(肮脏的方式)。或按照this 链接所说的(正则表达式)

    【讨论】:

      猜你喜欢
      • 2012-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多