Reputation: 11
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?
Upvotes: 0
Views: 142
Reputation: 117
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();
remove the unwanted content html tag using remove().
doc.select("span[style*=display:none]").remove(); //put unwanted tag inside.
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.
Upvotes: 1
Reputation: 720
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
Upvotes: 0