tags:

views:

186

answers:

2

Hi, all.

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.

+5  A: 

Do not parse HTML using regular expressions.

Instead, use an HTML Parser.

SLaks
Just to clarify the point:http://www.codinghorror.com/blog/archives/001311.html
CaseyB
I added your link.
SLaks
A: 

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.

Bryan Denny