How to replace a body in html file

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



How to replace a body in html file



I'm using android studio



I need to replace the body of an html document with other codes, this is an example that I tried to follow


protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.grafico);

wv = (WebView) findViewById(R.id.prova);
wv.setWebViewClient(new MyWebViewClient());

new BackgroundWorker().execute();



// load links in WebView instead of default browser
private class MyWebViewClient extends WebViewClient

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url)
view.loadUrl(url);
return false;


@RequiresApi(21)
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request)
view.loadUrl(request.getUrl().toString());
return false;



private class BackgroundWorker extends AsyncTask<Void, Void, Void> {

@Override
protected Void doInBackground(Void... arg0)
getDarewod();
return null;


public void getDarewod()

try
Document htmlDocument = Jsoup.connect(url).get();
Element element = htmlDocument.select("#gkHeaderMod > div.grafico-quotazione").first();

// replace body with selected element


htmlDocument.body().empty().append(element.toString());
final String html = htmlDocument.toString();

uiHandler.post(new Runnable()
@Override
public void run()
wv.loadData(html, "text/html", "UTF-8");

);
catch (IOException e)
e.printStackTrace();




I want to replace the all body with the code in my element variable. However this line doesn't works. How can I do?


htmlDocument.body().empty().append(element.toString());





can you show an example of what element.toString() is? is this a string containing html tags? Instead of append, have you tried innerHTML = ... And it doesn't work because of what, which error occurs?
– Calvin Nunes
Aug 10 at 19:13


element.toString()


append


innerHTML = ...









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard