How to cut all the tags from the String or just ignore them when outputting, or just not getting them jsoup, heard about the XMLreader there seems to be customized. But it is not known that the next time they will flood the site. I use Html.fromHtml to display text with markup, I get it through jsoup. And which way is less affected by performance.

Here is an example html

<td style="padding-left:10px; padding-right:10px; text-indent: 25px;" align="justify"> <p style="text-align: justify;">текст1</p> <p style="text-align: justify;">текст2</p> <p style="text-align: justify;"> <img alt="" src="/images/IMG_1367.jpg" style="width: 400px; height: 300px;"></p> </td> 

You need to cut this tag <img alt="" src="/images/IMG_1367.jpg" style="width: 400px; height: 300px;"> number of images is different, can be anywhere (between text for example)

I get the markup like this Elements elements = document.select("td[style]"); newsContent = elements.html(); Elements elements = document.select("td[style]"); newsContent = elements.html();

I deduced textView.setText(Html.fromHtml(newsContent));

Hml reader is an extreme way, I think there are many ways and I'm interested.

    1 answer 1

     Elements imgs = document.select("img"); document.remove(imgs); Elements elements = document.select("td[style]"); newsContent = elements.html(); 
    • I also need to get img - Artem
    • @ Artem, well, they are in the variable imgs ... - YuriySPb
    • Does he not cut them when connected? I have a mistake in what could be the matter? remove () in Node cannot be applied - Artem
    • And I understood everything, all questions disappear, I thought the document.remove to connect is coming - Artem
    • And nevertheless, nefig is not clear document should the main one be chosen? (Like one more select?) - Artem