安卓:code的解析HTML块 [英] Android : Parse HTML block of code

查看:107
本文介绍了安卓:code的解析HTML块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下一段HTML code,我需要解析检索的球员的名字,他已经打进了奔跑。
在这种情况下,它的'罗斯泰勒'和9。
怎样做解析这些信息的最佳方式?不想使用HTML解析器。
是正则表达式的最佳方法(我知道人都死了反对这个!但是,我只想信息的这2位,因此不希望使用的解析器)?
我已经费尽我应该如何找出其中的球员名字是在HTML文件中,并具有得分奔跑随之而来的排我的大脑。
下面的HTML注释部分是硬codeD之一。我能达到这个地方。然后检索标签的名称。这是一个好办法做到这一点?
另外我怎么获取即时下一行的运行一部分?


 <  - < A HREF =JavaScript的:无效(0);的onClick =返回showHwkTooltip(这一点,lvpyrbat1');类=livePlayerCurrent> *卢克·伍德科克< / A>  - >< A HREF =/ icc_cricket_worldcup2011 /内容/电流/播放/ 38920.html目标=_空白级=livePlayerCurrent称号=查看玩家资料的罗斯·泰勒>
*罗斯·泰勒
&所述; / A> <跨度风格=保证金左:为5px;标题=左手蝙蝠>(LHB)LT; / SPAN>   < / TD>
   < TD>< B> 9< / B>< / TD>
   &所述; TD> 9&下; / TD>
   &所述; TD→1&下; / TD>
   &所述; TD> 0℃; / TD>
   &所述; TD> 100.00&下; / TD>
   < TD>< / TD>
   < TD合并单元格=3align =left><跨度类=batStyl>前锋< /风格与GT;< / TD>
   < TD>< / TD>
   < TD合并单元格=8>< / TD>
  < / TR>


请让我知道如果你需要更多的信息。

问候,
山姆


解决方案

  

什么是做解析这些信息的最佳方式?


<一个href=\"http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags\">Use一个HTML解析器。


  

不想使用HTML解析器。


<一个href=\"http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags\">I不同意。


  

时的正则表达式的最好方法


<一个href=\"http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags\">No.

I have the following piece of HTML code which I need to parse to retrieve the player name and the runs he has scored. In this case it's 'Ross Taylor' and 9. What's the best way to do parse this info? Don't want to use an HTML parser. Is REGEX the best way (I know people are dead against this! But I just want these 2 bits of info and hence don't want to use a parser)? I've been racking my brains on how I should figure out where the player name is in the html file and the consequent row which has the runs scored. The HTML comment part below is a hard coded one. I can reach this place. Then retrieve the name between the tags. Is this a good way to do it? Also how do I retrieve the runs part in the immediate next row?


<!-- <a href="javascript:void(0);" onClick="return showHwkTooltip(this, 'lvpyrbat1');" class="livePlayerCurrent">*Luke Woodcock</a>-->

<a href="/icc_cricket_worldcup2011/content/current/player/38920.html" target="_blank" class="livePlayerCurrent" title="view the player profile for Ross Taylor">
*Ross Taylor
</a>    <span style="margin-left:5px;" title="left-hand bat">(lhb)</span >

   </td >
   <td><b>9</b></td>
   <td>9</td>
   <td>1</td>
   <td>0</td>
   <td>100.00</td>
   <td></td>
   <td colspan="3" align="left"><span class="batStyl">striker</style></td>
   <td></td>
   <td colspan="8"></td>
  </tr>


Please let me know if you need more info.

Regards, Sam

解决方案

What's the best way to do parse this info?

Use an HTML parser.

Don't want to use an HTML parser.

I disagree.

Is REGEX the best way

No.

这篇关于安卓:code的解析HTML块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆