iOS---过滤掉json中的html标签

html标签:如 </span></span></p>

[self flattenHTML:str];
//方法
- (NSString *)flattenHTML:(NSString *)html { 
    NSScanner *theScanner; 
    NSString *text = nil; 搜索
 theScanner = [NSScanner scannerWithString:html]; 
while ([theScanner isAtEnd] == NO) { 
        // find start of tag 
        [theScanner scanUpToString:@"<" intoString:NULL] ; 
        // find end of tag 
        [theScanner scanUpToString:@">" intoString:&text] ; 
        // replace the found tag with a space 
        //(you can filter multi-spaces out later if you wish) 
        html = [html stringByReplacingOccurrencesOfString: 
                [NSString stringWithFormat:@"%@>", text] 
                                               withString:@""]; 
 } // while // 
    NSLog(@"-----===%@",html); 
    return html; 
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • HTML标签解释大全 一、HTML标记 标签:!DOCTYPE 说明:指定了 HTML 文档遵循的文档类型定义(D...
    米塔塔阅读 3,310评论 1 41
  • 第一节:HTML基础 什么是浏览器 浏览器是网页运行的平台,常用的浏览器有IE、火狐(Firefox)、谷歌(Ch...
    单行道MY阅读 1,184评论 0 14
  • HTML5 标签comment 注释标签用于在源文档中插入注释。注释内容不会被浏览器显示。为代码编写注释的好处是...
    才気莮孒阅读 4,082评论 1 25
  • 在前一篇文章中已经简单提到Html标签了,在本文中就不再赘述它的介绍了。想要再看看的可以戳Html+Css基础概要...
    年少有van阅读 898评论 0 14
  • 2016,深秋之际,黄叶凋零,秋雨渐寒,一行十人相熟的朋友,踏上了憧憬已久的热带巴厘岛之旅。 巴厘岛是...
    达观天下阅读 601评论 0 4