I've this HTML block:
<div class="singolo-contenuto link_azure">
<p>I'm a TEXTXXXXXXXXXXXXXXXX<p>
<a href="http://example.com">Name of URL</a></p></p>
<ul class="list_attachments"><li><a
href="DON'T TOUCH"><img src='/img/fileicons/file.png' alt='file'/> TITLE</a></li></ul>
</div>
<div class="clear"></div>
document.select(".singolo-contenuto").text();
You can replace all links by text as you want then call .text()
pseudo code:
for (Element elem : document.select(".singolo-contenuto a")) {
if(elem.parents().hasClass("list_attachments")) continue;
String href = elem.attr("href");
String text = elem.text();
elem.replaceWith(new TextNode(href + " " + text, ""));
}
String result = document.select(".singolo-contenuto").text();