0

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?

1 Answer 1

2

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.

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

3 Comments

Tnx for reply but the page that I'm refering to is www.mtel.ba/imenik/rezultat.php (you put name or nuber in text box and select town from drop down list and you get results eg. phone number or adress) and it's not my webpage (I don't have access to page api). So I don't know how to do that.
I also tried to put rez String in webview code String html = getIntent().getExtras().getString("html"); setContentView(R.layout.browser); WebView webView = (WebView) findViewById(R.id.webview); webView.getSettings().setJavaScriptEnabled(true); webView.setWebChromeClient(new WebChromeClient()); webView.loadData(html, "text/html", "utf-8"); but the webview doesn't display anything meaningful.
see my edit to my answer. It looks like JTidy (stackoverflow.com/questions/238036/java-html-parsing) is a decent option for parsing HTML in java

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.