I want to parse following code to html code and show in a WebView
. This works fine, but...
Code to parse:
<img src="http://...jpeg" alt="„Indoor Maps“ von Google" align="left" style="padding-right:5px">\n\n\nEinfachere Navigation in Gebäuden verspricht Indoor Maps von Google. Der Praxis-Test von COMPUTER BILD im Hamburger „Alsterhaus“ verlief aber kurios.<br>Foto: ComputerBILD<br>
attempt 1) Html.toHtml(Code)
- The umlauts and quotes of the texts where parsed fine and the img-tag is still valid (quotes). But some img-attributes were removed, like alt
and align
. Result:
<p><img src="http://...jpeg"> Einfachere Navigation in Gebäuden verspricht Indoor Maps von Google. Der Praxis-Test von COMPUTER BILD im Hamburger „Alsterhaus“ verlief aber kurios.<br>\nFoto: ComputerBILD<br>\n</p>\n
attempt 2) external library: org.apache.commons.lang3.StringEscapeUtils.escapeHtml4(Code)
- All umlauts and quotes where parsed. The img-tag is corrupted by parsing the quotes. Now i can't show the image on a WebView
. The img-tags where not removed. Result:
<img src="http://...jpeg" alt="„Indoor Maps“ von Google" align="left" style="padding-right:5px">\n\n\nEinfachere Navigation in Gebäuden verspricht Indoor Maps von Google. Der Praxis-Test von COMPUTER BILD im Hamburger „Alsterhaus“ verlief aber kurios.<br>Foto: ComputerBILD<br>
I know there are a lot of posts of this category, but I can't find help to parse the html code and don't "touch" the quotes of attributes. I am stucking.
EDIT
This is the full Html code
StringBuilder html = new StringBuilder();
html.append("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
html.append("<html>");
html.append("<head>");
html.append("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=ISO-8859-1\">");
html.append("<title></title>");
html.append("</head>");
html.append("<body bgcolor=\"white\" leftmargin=\"0\" topmargin=\"0\">");
html.append(CODE AT THE TOP);
html.append("</body>");
html.append("</html>");
When I use UTF-8 I got the same result...
webView.loadData(html.toString(), "text/html", "iso-8859-1");
@Christiaan: This is the current result, when i set the unparsed code to WebView