【问题标题】:how to remove the html tag in iphone while parsing?解析时如何删除iphone中的html标签?
【发布时间】:2011-05-19 18:52:09
【问题描述】:

在解析一些 html 标记时添加到数组中,我需要删除该标记

例子

<img src=http://www.browndailyherald.com/polopoly_fs/1.2421290!image/4027750474.jpg_gen/thumbnails/100x100/4027750474.jpg><br /><br><p>
Andrew Furnas '11 has been named a recipient of the Marshall Scholarship, a nationally competitive fellowship which sponsors two years of graduate study in the United Kingdom....</p>

我需要删除 &lt;img&gt; 标签并只显示内容

请帮帮我

【问题讨论】:

  • 我认为它与 CDATA 有关 - 谷歌它
  • @benhowdle89- 我不知道 CDATA.... 我也没有使用它

标签: iphone html xml-parsing


【解决方案1】:

将其存储在 NSSMutableString 中,然后使用函数 deleteCharactersInRange 删除不需要的内容。

您需要通过搜索 NSMutableString 来确定范围。

所有解决方案都可以在 google 上轻松找到。

【讨论】:

  • hai 它可以工作,谢谢,但我需要为具有相同类的不同类型的 xmlparsing 执行此操作。每个解析都与其他解析不同,因此它仅适用于特定解析
【解决方案2】:

您可以使用Three20Core 删除 HTML 标签。

 [yourString stringByRemovingHTMLTags];

【讨论】:

  • 嘿,我没有在我的应用中使用 Facebook,请给我一个简单的解决方案
  • 你不需要使用脸书。没有比这更简单的了。你只需要安装three20core(有一个python脚本可以帮助你),然后添加NSStringAdditions。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-07-23
  • 2014-07-08
  • 2011-04-04
  • 1970-01-01
  • 2018-06-21
  • 2012-12-06
相关资源
最近更新 更多