Traversing String html

0

Good afternoon!

I'm getting a html String to display in a webview.

Within this string there may or may not be images, but for me to display it, I have to pass a base URL before src = \ "crmResources /, example:" link ... " p>

Then I have to save the entire String until I find an image, save it to another variable by concatenating it with a URLBases variable (example: link ), see if there are more images to do the same job and in the end concatenate everything in a String to display in webview.

What would be the best way or logic to do this? Remembering that there may or may not be images, and between them there may be other html elements.

    
asked by anonymous 06.11.2015 / 17:19

1 answer

1

If at any time you are using relative path, as in your example, and based on this http address, you can use the loadDataWithBaseURL ". It goes like this more or less:

webView.loadDataWithBaseURL("http://desenv.ex.com.br", strHtml, "text/html", "utf-8", "about:blank");

With this, your WebView will be based on this URL , and every relative path within this string will have it as a reference.

No need to go through all the Html. Remember that you need to have permission on your manifest for internet access.

    
06.11.2015 / 18:53