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

2
  • 2
    stackoverflow.com/questions/1732348/… Commented Apr 20, 2012 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 Commented Sep 14, 2012 at 21:09

1 Answer 1

1

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

Sign up to request clarification or add additional context in comments.

2 Comments

Ok, I'll look into it. Thanks. How about simple tags ? would it still not work. Like <tbody></tbody> for example.
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.