简体   繁体   English

如何在没有 jsoup 或任何其他第三方的情况下在 java 上读取 html?

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

I have a StringBuilder object in my class which I want to display on UI.我的 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. 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.

Note: I don't want to remove these tags and get a plain text.注意:我不想删除这些标签并获得纯文本。 Rather if there is a <br> tag it should break line while displaying the text.相反,如果有一个<br>标签,它应该在显示文本时换行。 Also, due to project restrictions I don't want to use any third party like jsoup etc.另外,由于项目限制,我不想使用任何第三方,如 jsoup 等。

Any help to achieve this would be appreciated!任何帮助实现这一目标将不胜感激!

How about simple .toString().replaceAll with specific replacements?带有特定替换的简单.toString().replaceAll怎么样? Like:喜欢:

<br> = \r\n <br> = \r\n

<li> = \r\n • <li> = \r\n •

...and so on.. ...等等..

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java中的HttpClient而不使用任何第三方库 - Httpclient in java without using any third party libraries 如何使用Java发送和读取第三方javascript变量 - How to use Java to sent and read a third party javascript variables 没有第三方库,如何完整解析HTML? - How can I full parsing HTML without third party library? 如何从 java 中的 class object 列表中获取第一个匹配元素的索引(不使用任何第三方库) - How to get index of first matched element from the list of class object in java (Without using any third party Library) 在没有 Java Mail API 或任何第三方 API 的情况下用 Java 编写 SMTP 客户端 - Writing SMTP Client in Java without Java Mail API or any third party API 是否可以在没有任何第三方库的情况下使用@RequestBody将JSON转换为Java bean - Is it possible to covert JSON to java bean with @RequestBody without any third party library 如何使用Jsoup读取HTML表 - How to read an HTML table with Jsoup 如何使两个不同的程序包访问彼此的类而又不允许任​​何其他第三个程序包在Java中访问它? - How to make two different packages access each other's classes without allowing any other third package to access it in java? 尝试不使用Jsoup解析HTML字符串。 我还有其他选择吗? - Tried to parse HTML String without using Jsoup. Do I have any other options? 如何将第三方Java库添加到Java - How to add third party java libraries to java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM