iphone - 在 iphone SDK 中删除特定的 HTML 标签

标签 iphone html ios xcode html-parsing

我有一个 NSString其中包含 HTML内容。但我想删除 < img src=..../>标记形式 NSString。

例如

Source = < p>< a href="http://wpcore.mpf.s3.amazonaws.com/wp-content/uploads/2012/12/thumbs_img_0500.jpg">**< img class="alignleft size-full wp-image-4730" style="margin-left: 5px; margin-right: 5px;" title="thumbs_img_0500" src="http://wpcore.mpf.s3.amazonaws.com/wp-content/uploads/2012/12/thumbs_img_0500.jpg" alt="thumbs img 0500" width="120" height="120" />**< /a>The two professional level < a title="3d printing" href="http://www.makepartsfast.com/category/products/3d-printers/">3D printers< /a> that build parts in color are the Zprinter from 3D Systems and the < a href="http://www.makepartsfast.com/2012/05/3812/mcor-announces-full-3d-color-3d-printer">Iris< /a> from Mcor Technologies. Earlier this year, Mcor Technologies announced its Iris full color 3D printer at the Rapid show and recently at Euromold. The Zprinter uses ink jetted into the build powder. The Iris, however, uses a different technique for creating color parts. Dr. Conor MacCormack, CEO of Mcor, discusses this technology.</p>
< p>< a href="http://wpcore.mpf.s3.amazonaws.com/wp-content/uploads/2012/12/MacCormack-part-1.mp3">MacCormack part 1< /a>< /p>

我的 img src 标签将一直不同。 我该怎么做??

我的代码:

-(void)viewWillAppear:(BOOL)animated
{
source = [NSString stringWithFormat:@"%@",[[self.parseResults objectAtIndex:k] objectForKey:@"summary"]];

NSLog(@"%@",source);
}

最佳答案

我通过将 HTML 转换为字符串来解决这个问题。

只需导入两个文件 NSString+HTML.h & NSString+HTML.m 文件。

然后调用 text_str=[html_str stringByConvertingHTMLToPlainText];

关于iphone - 在 iphone SDK 中删除特定的 HTML 标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13946216/

相关文章:

iphone - iPhone Safari 上的定位和字体大小问题

iphone - 如何向 UITableView 添加一次性部分和部分标题?

javascript - 无法同时调整静态和可拖动元素的大小

javascript - 如何给已经有悬停动画的元素添加onclick事件

iphone - 在 AppDelegate 中以横向模式显示 UILabel

iphone - 我们可以获取 iPhone 中配置的总电子邮件帐户吗?

iphone - 在 GCD block 中绘制图像时卡顿

html - HTML 中的 CSS 代码无效

objective-c - 在 iOS 中使用自定义导航栏

ios - WatchKit 项目无法识别 presentAudioRecordingControllerWithOutputURL