我寫了一個代碼來讀取來自XML文件(Feed)的新聞..我必須在我的列表視圖中顯示每個項目的描述...並且我用這個代碼豌豆去除html標籤說明標籤內部存在:如何使用正則表達式從java中的字符串中刪除一些html標記
else if ("description".equals(tagName)){
sourcedescription= parser.nextText();
description=Html.fromHtml(sourcedescription).toString();
Log.d("msg", description);
feedDescription.add(description);
}
一些項目我成功沒有標籤的理解方式,即以顯示其描述,但是我忘了刪除所有標籤爲其他一些具有{iframe} {/ iframe}標籤的項目...我認爲這個標籤存在於沒有描述的項目的描述標籤中
<description><![CDATA[<p>{iframe height="600"}<a href="http://admreg.yu.edu.jo/index.php?option=com_content&view=article&id=606:------20132014&catid=87:2011-01-25-18-12-08&Itemid=438">http://admreg.yu.edu.jo/index.php?option=com_content&view=article&id=606:------20132014&catid=87:2011-01-25-18-12-08&Itemid=438</a><span style="line-height: 1.3em;">{/iframe}</span></p>]]></description>
我的問題是如何通過使用正則表達式來刪除iframe標記?
爲什麼是正則表達式?爲什麼不使用適當的工具來完成這項工作,比如XPath? – EJP
http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 –