0

In my android app whole web page is loading in web view to which i gave the link, but I want to load only some component from that web page not rest of the component. Can anybody tell me is it possible to load only required component from web page and how?

Apurva
  • 11
  • 1
  • 4
  • 1
    Probably you are searching this: http://stackoverflow.com/questions/14423981/android-webview-display-only-some-part-of-website – michoprogrammer Oct 25 '13 at 09:50

2 Answers2

1

It can be done using Jsoup html parsing library.

1.Get the data from url to jsoup document.

Document doc = Jsoup.connect("http://example.com/").get();

  1. remove the unwanted content html tag using remove().

    doc.select("span[style*=display:none]").remove(); //put unwanted tag inside.

  2. Save the remaining content to a string.

    String newcontent=doc.toString();

4 Set the newcontent as Webview content.

webView.loadDataWithBaseURL(null, newcontent, "text/html", "UTF-8", null);

Sorry for poor english.

Carnage
  • 117
  • 5
0

I dont know if there is a standard api to do this, but if not you could load the html first then manipulate it. So you could delete the areas you dont need and only display the necessary parts.

Cheers

ZeusNet
  • 710
  • 9
  • 25
  • You could use javascript as it's mentioned in the link that @MachoProgrammer gave. One other opportunity is to get the html as string via an HTMLConnection and then manipulate the string. For this you will find a fairly large quantity of examples in the web – ZeusNet Oct 25 '13 at 10:23