I tested Jsoup and I cannot remove text indexes of unwanted tags. Idk if I am wrong. Method:
String pretty = Jsoup.clean("<img src=\"marco\">Capretta</img><i>Sono misterioso</i><p color=\"white\"><font size=\"5\">Ciao</p><p>some text</p><br/> <p>another text</p></font>" , "", Whitelist.basic().addTags("br", "p","i"), new Document.OutputSettings().prettyPrint(true));
System.out.println(pretty);
Result:
Capretta
<i>Sono misterioso</i>
<p>Ciao</p>
<p>some text</p>
<br>
<p>another text</p>
But I don't need text notes <img>(also valid for other unwanted tags) ...
So the result is better:
<i>Sono misterioso</i>
<p>Ciao</p>
<p>some text</p>
<br>
<p>another text</p>
I may have another html ...
Ps The question is that Java, not Javascript !!!
source
share