我有以下 XML 提要:
I have follows below XML feed:
<Description>
<p>Touch, tap, flip, slide! You don't just read Books, you experience it.</p>
</Description>
这里我必须显示类似
触摸、点击、翻转、滑动!你不 39.just read the Books, you experience it.
在这里我处理了解析器:
Here I have handled the parser like:
public static String removeHTML(String htmlString)
{
// Remove HTML tag from java String
String noHTMLString = htmlString.replaceAll("\<.*?\>", "");
// Remove Carriage return from java String
noHTMLString = noHTMLString.replaceAll("
", "<br/>");
noHTMLString = noHTMLString.replaceAll("<([bip])>.*?</1>", "");
// Remove New line from java string and replace html break
noHTMLString = noHTMLString.replaceAll("
", " ");
noHTMLString = noHTMLString.replaceAll(""", """);
noHTMLString = noHTMLString.replaceAll("<(.*?)\>"," ");//Removes all items in brackets
noHTMLString = noHTMLString.replaceAll("<(.*?)\
"," ");//Must be undeneath
noHTMLString = noHTMLString.replaceFirst("(.*?)\>", " ");
noHTMLString = noHTMLString.replaceAll(" "," ");
noHTMLString = noHTMLString.replaceAll("&"," ");
return noHTMLString;
}
在 endElement 中:
In endElement :
public void endElement(String uri, String localName, String qName)throws SAXException {
currentElement = false;
if (localName.equalsIgnoreCase("Description")){
sitesList.setDescription(currentValue);
String Sub_arry=n+currentValue;
Appscontent.Sub_arraylistdes.add(Sub_arry);
String stringWithoutHTML=removeHTML(currentValue);
System.out.println("description value----->"+n+att_ID+"------>>"+stringWithoutHTML);}
现在我必须运行该应用程序,这意味着 html 标记与我的描述一起显示...在这里如何删除 HTML 标记?请为我提供解决方案???
Now i have to run the app means the html tag is displayed with my description...Here how can I remove the HTML tag? please provide me solution for these ???
我希望显示没有 Html 标记的描述...请为这些提供解决方案.
i wish to display the description without Html tags...please provide e solution for these.
if (localName.equalsIgnoreCase("Description")){
sitesList.setDescription(currentValue);
String Sub_arry=n+currentValue;
StringBuffer sb = new StringBuffer();
sb.append(Sub_arry);
String newString = sb.toString();
Appscontent.Sub_arraylistdes.add(newString);
System.out.println("description value----->"+n+att_ID+"------>>"+newString);}
public static String html2text(String html) {
return Jsoup.parse(html).text();
}
在 endElement:
In endElement:
if (localName.equalsIgnoreCase("Description")){
sitesList.setDescription(currentValue);
String Sub_arry=n+currentValue;
Appscontent.Sub_arraylistdes.add(Sub_arry);
String stringWithoutHTML=html2text(currentValue);
System.out.println("description value----->"+n+att_ID+"------>>"+stringWithoutHTML);}
但我没有得到 o/p..请为我提供解决方案???如何删除这些描述中的 html 标签...
But i didn't get the o/p..pls provide me solution for these ??? how can i remove the html tags in these description...
您可以使用 Android 中内置的 HTML 类轻松删除 Android 中的任何 HTML 标签.导入 android.text.Html;.现在,考虑到数据"是具有 HTML 标记的字符串变量,您可以使用 Html.fromHtml(data).toString() 来取回没有任何 HTML 标记的字符串.
You can easily remove any HTML tag in Android using the built-in HTML class in Android. Import android.text.Html;. Now, considering "data" is your String variable which has HTML tags, you use Html.fromHtml(data).toString() to get back the string without any HTML tags.
这篇关于删除android中的html标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!
上传进度侦听器未触发(Google 驱动器 API)Upload progress listener not fired (Google drive API)(上传进度侦听器未触发(Google 驱动器 API))
使用 Google Drive SDK 将文件保存在特定文件夹中Save file in specific folder with Google Drive SDK(使用 Google Drive SDK 将文件保存在特定文件夹中)
Google Drive Android API - 无效的 DriveId 和 Null ResourcGoogle Drive Android API - Invalid DriveId and Null ResourceId(Google Drive Android API - 无效的 DriveId 和 Null ResourceId)
谷歌驱动api服务账户查看上传文件到谷歌驱动使Google drive api services account view uploaded files to google drive using java(谷歌驱动api服务账户查看上传文件到谷歌驱动使用java
Google Drive 服务帐号返回 403 usageLimitsGoogle Drive service account returns 403 usageLimits(Google Drive 服务帐号返回 403 usageLimits)
com.google.api.client.json.jackson.JacksonFactory;Google Drcom.google.api.client.json.jackson.JacksonFactory; missing in Google Drive example(com.google.api.client.json.jackson.JacksonFactory;Google Drive 示例