I have a JSP page, with some info pulled from Mongo DB. The outcome HTML page has UTF-8 encoding. Occasionally this char is being pulled from the DB: –, the en dash. When the page displayed in browser - this char is being displayed OK. But when in Android Webview - I see a question mark instead of it.
Any ideas how to solve it without touching the Mongo DB?
EDIT
Short HTML outcome:
<head>
<meta charset="utf-8">
....
</head>
...
<div class="photo_description">
<h1>
<span class="text-ellipsis">
NY – The sunrise
</span>
</h1>
<div class="button">
<div class="btn-txt">
View
</div>
</div>
...
</div>
...
Notice the dash in the <span> element.
I found an answer here:
${fn:escapeXml(photoTitle)}
Related
I am new with ionic framework.Currently i am working on ionicsidemenu app. I want to show records according to date, having date as heading and respective date having multiple records.
For this i have two web services one is for heading date another is for date-wise records. In my HTML file i have two ng-repeat one is for display heading date. Now i am not able to understand how to get records of particular date as date has to be sent to web service for getting records.
I have tried this:
<div ng-repeat="d in dates track by $index">
<h2>d.edate</h2>
<div ng-init="datewiserecords(d.edate);" >
<div ng-repeat="n in res1 track by $index" class="text-white" >
</div></div></div>
but its not working.Please help me.
I am not sure what you are looking for, but the way I understand the question makes me to give you a solution as below:
My Solution:
<!DOCTYPE html>
<html>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>
<div ng-app="myApp" ng-controller="myCtrl">
<ul>
<li ng-repeat="get_date in dates">
<h2>{{get_date.date}}</h2>
<h4>{{get_date.data}}</h4>
</li>
</ul>
</div>
<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
$scope.dates = [{date:"1",data:"One"},{date:"2",data:"Two"},{date:"3",data:"Three"}];
});
</script>
</body>
</html>
Hope This is helpful
I have a html text in
<html>
<head></head>
<body>
<div id="carousel-generic" class="banner-erbj carousel slide" data-ride="carousel"> <ul class="carousel-indicators"> <li class="active" data-target="#carousel-generic" data-slide-to="0">0</li> <li data-target="#carousel-generic" data-slide-to="1">0</li> </ul> <div class="carousel-inner"> <div class="item active"><img src="imagesrcpath" alt="" /></div> <div class="item"><img src="imagesrcpath" alt="" /></div> </div> </div>
</html>
</body>
I want to take out the link in it and display in a webview.
I have tried the jsoup method and some solutions provided in the questions on stackoverflow also but not able to find anysolution .. please help
After lot more of digging i found the solution to it :
Spanned parsed = Html.fromHtml(text);
String finalstr = ("<html><body>").concat(parsed.toString()).concat("</body></html>");
mWebView.setInitialScale(30);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setLoadWithOverviewMode(true);
/*mWebView.getSettings().setLayoutAlgorithm(WebSettings.LayoutAlgorithm.SINGLE_COLUMN);*/
mWebVie.getSettings().setUseWideViewPort(true);
mWebView.loadData(finalstr, "text/html", "UTF-8");
This whole set of instructions helped me do the same.
Use regex.
<img.+?/>
will simply find image tags.
Learn XPATH
http://www.w3schools.com/xml/xpath_intro.asp
and use your xpath knowledge in
http://htmlcleaner.sourceforge.net/, to get whatever you want from html
You can take advantage of the power of REGEX here.
Pattern pattern = Pattern.compile("/src=\"(.*)\"/");
Matcher matcher = pattern.matcher(YOURHTML);
matcher.group(1); // this way you can read all of the srcs
Disclaimer: the regex above is not tested.
I'm developing my first phonegap application. I am trying to get some datas from a web server and then show them in the collapsible list. However, I couldn't add datas to list dynamically. Additionally, the list structure is shown in web page but i couldn't see anything on the android emulator. I just see black page on it. How can solve these problems? Can anyone help about that? Thank you in advance.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.
mobile-1.3.2.min.css">
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://code.jquery.com/mobile/1.3.2/jquery.mobile-1.3.2.min.js"
></script>
</head>
<body>
jQuery Mobile Collapsibles
<div id = "outer" data-role="content">
<div id="list" data-role="collapsible-set">
<div id="first" data-role="collapsible">
<h3>Güvenlik</h3>
<p id="guvenlik">I'm the expanded content.</p>
</div>
<div id="second" data-role="collapsible">
<h3>Sağlık</h3>
<p id="saglik">I'm the expanded content.</p>
</div>
<div id="third" data-role="collapsible">
<h3>Diğer Servisler</h3>
<p id="diger">I'm the expanded content.</p>
</div>
</div>
<button id="Sorgula">Sorgula</button>
</div>
<script>
$(document).ready(function()
{
...
});
</script>
</body>
</html>
You can insert items from list like I did, or you can just write it as inside the each function.
The find call at the end is just to close them when it ends.
$.each(list, function(index, value) {
$("#container").append('<div data-role="collapsible" data-iconpos="right" class="ui-collapsible ui-collapsible-inset ui-corner-all ui-collapsible-themed-content ui-collapsible-collapsed ui-first-child ui-last-child">'+
'<h3 class="ui-collapsible-heading ui-collapsible-heading-collapsed">'+value.name+
'<ul data-role="listview">'+some_li_list+'</ul>'+
'</div>');
});
$('#container').find('div[data-role=collapsible]').collapsible();
I made a simple example using the android plugin for printplugin
Here the plugin:
https://github.com/EionRobb/phonegap-print-plugins/tree/master/Android
My code is:
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>Prueba de Impresion</title>
<link href="jquery-mobile/jquery.mobile-1.0a3.min.css" rel="stylesheet" type="text/css">
<script src="jquery-mobile/jquery-1.5.min.js" type="text/javascript"></script>
<script src="jquery-mobile/jquery.mobile-1.0a3.min.js" type="text/javascript"></script>
<script src="phonegap.js" type="text/javascript"></script>
<script src="printplugin.js" type="text/javascript"></script>
</head>
<body>
<script type="text/javascript">
function imprime(){
var html = document.getElementById("printHTML").innerHTML;
window.plugins.printPlugin.print(html,
function(result) {
alert("print ok");
},
function(result) {
if (!result.available){
alert("no printing available");
}
else{
//Localised error description
alert(result.error);
}
}
);
}
</script>
<div data-role="page" id="page">
<div data-role="header">
<h1>Prueba de Impresion</h1>
</div>
<div data-role="content">
<button data-icon="gear" onClick="imprime();">Imprimir</button>
Contenido</div>
<div id="printHTML">
<div style="color: red;">
<p>Either the well was very deep, or she fell very slowly, for she had plenty of time as she went down to look about her and to wonder what was going to happen next. First, she tried to look down and make out what she was coming to, but it was too dark to see anything; then she looked at the sides of the well, and noticed that they were filled with cupboards and book-shelves; here and there she saw maps and pictures hung upon pegs. She took down a jar from one of the shelves as she passed; it was labelled 'ORANGE MARMALADE', but to her great disappointment it was empty: she did not like to drop the jar for fear of killing somebody, so managed to put it into one of the cupboards as she fell past it.</p>
</div>
<div style="color: green; page-break-before:always;">
<p>In the Propontis, as far as I can learn, none of that peculiar substance called BRIT is to be found, the aliment of the right whale. But I have every reason to believe that the food of the sperm whale—squid or cuttle-fish—lurks at the bottom of that sea, because large creatures, but by no means the largest of that sort, have been found at its surface. If, then, you properly put these statements together, and reason upon them a bit, you will clearly perceive that, according to all human reasoning, Procopius's sea-monster, that for half a century stove the ships of a Roman Emperor, must in all probability have been a sperm whale.</p>
</div>
<div style="color: blue; page-break-before:always;">
<p>They were not their families, nor their wives, nor their servants; the relationship was peculiar, and so unlike anything known to us that it is most difficult to describe. All property among the green Martians is owned in common by the community, except the personal weapons, ornaments and sleeping silks and furs of the individuals. These alone can one claim undisputed right to, nor may he accumulate more of these than are required for his actual needs. The surplus he holds merely as custodian, and it is passed on to the younger members of the community as necessity demands.</p>
</div>
</div>
<div data-role="footer">
<h4>Pie</h4>
</div>
</div>
</body>
</html>
the application runs and displays the message: no printing available, and in logcat I see the following message:
Error: Status=undefined Message=Class not found at file:///android_asset/www/phonegap.js:473
I have installed 1.4.4 send2printer
if someone could tell me I'm doing wrong
Thanks to all in advance
I am trying to make "Highlighter" for epub reader in one my Android project using webview.
I am using Rangy for getting Selected text.
The serialize functions gives me this value after selecting text from the below sample HTML:
2/5/3/5/1/2:0,13/5/3/5/1/2:24
I am storing this in DB. When user returns to this page, i am retrieving the same selection and trying to deserialize but the deserialize function throws the following error:
Error in Rangy Serializer module: deserializePosition failed: node <DIV>[7] has no child with index 13, 0
I am getting why this is happenig??
Even i am trying to do the same thing using XPath but still the same issue.
<html>
<head>
<script></script>
</head>
<body>
<div id="mainpage" class="highlighter-context">
<div> Some text here also....... </div>
<div> Some text here also.........</div>
<div>
<h1 class="heading"></h1>
<div class="left_side">
<ol></ol>
<h1></h1>
<div class="text_bio">
In human beings, height, colour of eyes, complexion, chin, etc. are
some recognisable features. A feature that can be recognised is known as
character or trait. Human beings reproduce through sexual reproduction. In this
process, two individuals one male and another female are involved. Male produces
male gamete or sperm and female produces female gamete or ovum. These gametes fuse
to form zygote which develops into a new young one which resembles to their parent.
During the process of sexual reproduction
</div>
</div>
<div class="righ_side">
Some text here also.........
</div>
<div class="clr">
Some text here also.......
</div>
</div>
</div>
</body>
</html>
Any guesses??
you are probably using the following:
highlighter.highlightSelection();
rangy.serializeSelection();
if you are running highlightSelection before serializing it will not work.
this is because highlighting is actually wrapping text in tags which means that DOM is manipulated.
deserializing on original DOM will obviously won't work.
try change the order of commands so you will serialize first and only then use highlight.
Correct Order:
rangy.serializeSelection();
highlighter.highlightSelection();