1

I am a beginner on developing Android's application. I have some problems about using regular expressions in Android.

In my application, I had write some code for get back the source code of a html page which I had turn it in String datatype. And now I want to use regular expressions to retrieve some details in the html tags of this page. So, what should I do for it?

for example, in the html code,

<HTML>
.......
<TABLE class=tb_info cellSpacing=0 cellPadding=0 border=0>
<TR>
<TD class=pro_name vAlign=center colSpan=5>Abby Poon</TD>
</TR>
<TR>
<TD class=pro_name vAlign=center colSpan=5>Peter Pan</TD>
</TR>
</TABLE>
.........
</HTML>

And now I want to get back the value "Abby Poon" and "Peter Pan" which is in a table called "tb_info" and in a called "pro_name" for both two values. Can anyone teach me how I can do it? Or you may give me some reference page for it with Android. Thank you very much.

Michael Myers
  • 188,989
  • 46
  • 291
  • 292
Carmen
  • 11
  • 1

2 Answers2

5

Do not parse HTML using regular expressions.

Instead, use an HTML Parser.

Community
  • 1
  • 1
SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
0

HTML is not a regular language, therefore you cannot use Regular Expressions against it 100% successfully. You need to use some sort of HTML parser instead.

You don't want to be driven insane.

Community
  • 1
  • 1
Bryan Denny
  • 27,363
  • 32
  • 109
  • 125