I have a HTML String as By<!--[10018729]//--> <img src=\"http://images.thecarconnection.com/tny/avatar-image-for-ernst_100345731_0.jpg\" alt=\"Kurt Ernst\" width=\"20\" height=\"20\"/> Kurt Ernst, Contributor". I have to get data from the this string as the name as Kurt Ernst The Url as http://images.thecarconnection.com/tny/avatar-image-for-ernst_100345731_0.jpg. I don't know how to get it? Please suggest any solution regarding the same.
Thanks in advance.
I did this kind of parsing using my own logic. It has worked for me. You can get the String from the URL then use an if condition to get the title and src by writing a while or for loop. Break the loops when you get both the title and the src.
Related
I'm having an issue when using the EvaluteJavascript on both Android and iOS (I'm using Xamarin).
The issue is when I want to pass a string argument to a javascript function, if that string contains special character, the js compiler will not understand.
For example:
EvaluateJavascript("updateHtml('Some Html \n Some Html')")
But if i use, this will work:
EvaluateJavascript("updateHtml('Some Html Some Html')")
So the question is how am i able to pass entire string as argument to the javascript function in EvaluateJavascript.
Thanks in advance :)
I was able to solve my issue.
I encoded my string as URL encoding like this
EvaluateJavascript('$"updateHtml({Uri.EscapeUriString("Some Html \n Some Html"'})))
Then in my javascript i just need to decode it by using:
document.getElementById("body").innerHTML = decodeURI(html);
How about using "\\n" instead of "\n" ?
I just want to get the HTML String from my webview for that i am trying with the following code
webviewTxt.loadUrl("javascript:HTMLOUT.processHTML(document.documentElement.outerHTML);");
But i don't know how can i get this code to string. I even don't know whether this is true code to grab the HTML String or not.
In my webview i have following String
This is a test Demo
Where "test" is written in Italic and "Demo" is written in Bold So i want to get the HTML string from above code.
Above string is just an Example, The string may be anything not the same as above string each time.
If anyone is having any idea then please guide me, I already checked so many link links from SO and other google stuff but i am not able to grab the String in HTML from Webview.
I am getting some strings from json. My string contains special characters like "æ" from Næstved an many more like "ø" from køkken. But When I set Text these strings to ant textview, I get my strings printed in unusual way.
Example: For køkken I get kø ;kken.
I think I need to encode or decode my string somewhere but where I don,t know.
Please help.
Thanks in advance
The displayed version of your string represents an HTML encoded entity. You might want to verify that it is not coming in this way in your JSON data, but in any case, to decode it you can use the StringEscapeUtils.unescapeHtml4 method from Apache Commons Lang:
final String escaped = "køkken";
System.out.println(StringEscapeUtils.unescapeHtml4(escaped));
Output:
køkken
Did you check out the Latin Coding for your characters? I know the Ash character can be coded with æ and will show up æ in the browser.
Here is the a list of codes
Hope this helps!
My data in db is stored in html format along with image tags in it. So when I am getting the data from database I am removing the html tags and setting it to textview. My problem is even after removing the html tags, there is a small square box displaying in the emulator indicating that there is some image. How can I remove those square box in emulator which is an indication of image in that html data? Help me regarding this...
Thanks in advance
My Code:
textView.setText(Html.fromHtml(htmlString));
You could do a regex replace <img.+?> on htmlString.
textView.setText(Html.fromHtml(htmlString.replaceAll("<img.+?>", "")));
Untested
since images can look like:
<img ...></img>
and
<img... />
This solution will match both cases:
String htmlBody = htmlString.replaceAll("<img.+/(img)*>", "");
textView.setText(Html.fromHtml(htmlBody));
None of the answers are able to remove all possible img tags.
The most appropriate answer would be
String htmlBody = htmlString.replaceAll("(<(/)img>)|(<img.+?>)", "");
It will remove and tags both. And not remove any content between two images.
hi have a look on this example
String temp="<img>helloo</img><b> this is test</b>";
temp= temp.replace("<img>", "");
temp= temp.replace("</img>", "");
textView.setText(Html.fromHtml(temp));
In my project I am getting data from sqlite database and setting that data to my textviews. But the data which I am getting contains html tags which is looking odd when I am displaying. Can we remove those html tags after getting them from database? Please help me regarding this.
Thanks in Advance.....
you can use html tags instead to remove by following statement:
textView.setText(Html.fromHtml(htmlString));
Download the JSoup library from http://jsoup.org/, and use it this way:
Jsoup.parse(html).text();
This will return a String that you can put in your textview.