簡體   English   中英

如何在沒有 jsoup 或任何其他第三方的情況下在 java 上讀取 html?

[英]How to read html on java without jsoup or any other third party?

我的 class 中有一個 StringBuilder object,我想在 UI 上顯示它。 This object has few html tags for ex: <li> <br> etc. I would like to know how to format this object so that the html tags are not shown as it is on screen, however they are converted to a readable format.

注意:我不想刪除這些標簽並獲得純文本。 相反,如果有一個<br>標簽,它應該在顯示文本時換行。 另外,由於項目限制,我不想使用任何第三方,如 jsoup 等。

任何幫助實現這一目標將不勝感激!

帶有特定替換的簡單.toString().replaceAll怎么樣? 喜歡:

<br> = \r\n

<li> = \r\n •

...等等..

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM