【发布时间】:2014-09-18 19:48:09
【问题描述】:
我正在从事一个数据来自服务器的项目。在某些字段中,数据以 html 格式存储。我的问题是我想在 Android 文本视图中显示该信息。但不是这个 html 部分。但是,我想保持换行信息完整,以便它可以正确显示给用户。我试过 Jsoup.clean 但它也留下了一些样式表数据,比如,
<ul style="list-style-position: initial; list-style-image: initial; padding-top: 0px;
padding-right: 0px; padding-bottom: 0px; padding-left: 14px; font-family: Arial, Helvetica, sans-serif; font-size: 12px; margin: 0px;">
<li style="line-height: 18px; padding: 0px; margin: 0px;">Offer is on a choice of veg or non-veg meals for Two
<ul style="list-style-type: disc; list-style-position: initial; list-style-image: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 14px; line-height: normal; margin: 0px;">
<li style="line-height: 18px; padding: 0px; margin: 0px;"><strong>Offer 1- Rs.499 Worth Rs. 1000:</strong>&nbsp;Veg Lunch OR Dinner for 2 Persons</li>
<li style="line-height: 18px; padding: 0px; margin: 0px;"><strong>Offer 2 &ndash; Rs.599 Worth Rs. 1200:</strong>&nbsp;Non-Veg Lunch OR Dinner for 2 Persons</li>
</ul>
</li>
<li style="line-height: 18px; padding: 0px; margin: 0px;">Traditional restaurant serving authentic cuisine in mud pots</li>
<li style="line-height: 18px; padding: 0px; margin: 0px;">Inclusive of all taxes and service charges</li>
<li style="line-height: 18px; padding: 0px; margin: 0px;"><strong><span class="upc gry sml">Cost for 2: </span>Rs. 700</strong></li>
</ul>
应用 jsoup.clean 后字符串变为
<ul style="list-style-position: initial; list-style-image: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 14px; font-family: Arial, Helvetica, sans-serif; font-size: 12px; margin: 0px;"> <li style="line-height: 18px; padding: 0px; margin: 0px;">Offer is on a choice of veg or non-veg meals for Two <ul style="list-style-type: disc; list-style-position: initial; list-style-image: initial; padding-top: 0px; padding-right: 0px; padding-bottom: 0px; padding-left: 14px; line-height: normal; margin: 0px;"> <li style="line-height: 18px; padding: 0px; margin: 0px;"><strong>Offer 1- Rs.499 Worth Rs. 1000:</strong> Veg Lunch OR Dinner for 2 Persons</li> <li style="line-height: 18px; padding: 0px; margin: 0px;"><strong>Offer 2 – Rs.599 Worth Rs. 1200:</strong> Non-Veg Lunch OR Dinner for 2 Persons</li> </ul> </li> <li style="line-height: 18px; padding: 0px; margin: 0px;">Traditional restaurant serving authentic cuisine in mud pots</li> <li style="line-height: 18px; padding: 0px; margin: 0px;">Inclusive of all taxes and service charges</li> <li style="line-height: 18px; padding: 0px; margin: 0px;"><strong><span class="upc gry sml">Cost for 2: </span>Rs. 700</strong></li> </ul>
请帮我解决这个问题。
【问题讨论】:
-
为什么要投反对票?我犯了什么错误吗?请告诉我,以便我以后避免它。
标签: java android html css jsoup