1

I've been trying to make an app for a website for a while. I used webview at first, but now I'm creating my own app look with buttons, textview etc....

And whenever there is a query into the website database, I post into the site and get the contents(loaded html code into textview and webview) as seen in demo app pic below.

I used HttpPost and HttpResponse and everything works. Now, the remaining part is that I want to search through the string with the html code and get only the part that looks like the middle part in the webview in image below, which is the table in the middle with the main content.

The site is written completely using tables. and the part I want has this structure.

<td id="main_content" class="text"> 
    <table>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
            .
            .
            .
            depending on results
    </table> 
</td>

I know I can use JSON and php scripts to post and get results, but the thing is I don't have access to the webpage or the server. What is the regular expression to use in this case because I can't get it working. I only have basic knowledge in regular expression searching. Thank you.

app demo image

Misha Zaslavsky
  • 8,414
  • 11
  • 70
  • 116
Nesfe
  • 51
  • 1
  • 7
  • 2
    http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags?answertab=votes#tab-top – Beau Grantham Apr 20 '12 at 18:21
  • Pardon my asking a question for an answer,Nobody gave me what I needed here.. @Nesfe,How exactly did you search the website database without access to it.. I thought it was impossible – Oyeleke Okiki Sep 14 '12 at 21:09

1 Answers1

1

Consider using JSoup instead: Android JSoup Example. As another commenter noted, RegEx isn't really an appropriate tool for parsing HTML generally.

Community
  • 1
  • 1
kabuko
  • 36,028
  • 10
  • 80
  • 93
  • Ok, I'll look into it. Thanks. How about simple tags ? would it still not work. Like for example. – Nesfe Apr 20 '12 at 18:48
  • Technically you can probably get some variation of RegEx to work, it could be very complex and hard to get the values that you want though. JSoup is really pretty easy to use. I wouldn't bother with RegEx. – kabuko Apr 20 '12 at 18:51