majk
majk

Reputation: 183

How to parse results provided by Java script in Android

I'm working on android app that should send two parameters to web page form and I'm using HttpClient, HttpPost, HttpResponse to do that.

    HttpResponse responsePOST = client.execute(post);
    HttpEntity resEntity = responsePOST.getEntity();
    rez = EntityUtils.toString(resEntity);

In rez is complete HTML from page and I want to display results in TableLayout but can't get them. Now, results that I get are provided by Javascript function and Jsoup can't parse them, and they are just one part of web page. How can I get those results without trying to parse rez String using regex?

Upvotes: 0

Views: 2405

Answers (1)

Mike Marshall
Mike Marshall

Reputation: 7850

I would steer clear of returning HTML as a data exchange mechanism. If you are only interested in data I would instead return JSON (Link). I have had great success using the GSON library to parse JSON returned from my web endpoints/apis.

Edit

Saw your comment. If you need to walk the HTML DOM it looks like JTidy is a decent option. See this StackOverflow question.

Upvotes: 2

Related Questions