IOS中過濾HTML標簽
- (void)dooo
{NSLog(@"------"); NSString * str=@"<p style=\"text-align: center;\"><img style=\"width:94%;height:auto\" src=\"http://p1.img.cctvpic.com/photoworkspace/contentimg/2014/01/13/2014011318535072073.jpg\" alt=\"AC米蘭官方宣布阿萊格里下課\" width=\"500\"/></p><p style=\"text-align: center;\"><span style=\"color: #0000ff;\"><strong>AC米蘭官方宣布阿萊格里下課</strong></span></p><p><span style=\"color: #000000;\"> 北京時間1月13日晚6時,意甲AC米蘭俱樂部官方宣布主帥阿萊格里下課。昨天的意甲第19輪比賽中,AC米蘭客場3比4不敵升班馬薩索洛,比賽結束之后就傳出了阿萊格里將會被解雇的消息。</span></p><p><span style=\"color: #000000;\"> 米蘭的官方公告中寫道:“阿萊格里先生和他的助手們將不再擔任球隊一線隊教練的工作,對此我們非常遺憾,感謝阿萊格里和他的團隊幾年來為俱樂部做出的貢獻,祝愿他在未來的工作中繼續取得成功。”<span style=\"font-size: 14px;\">此前意大利方面的消息都是在阿萊格里下課后,前米蘭球星因扎吉將暫時接手球隊,不過米蘭官方公告中稱球隊的訓練和比賽任務暫時由助理教練毛羅-塔索蒂負責。</span></span></p><p><span style=\"color: #000000;\"> <span style=\"font-size: 14px;\">阿萊格里在2010年世界杯后上任成為AC米蘭隊主教練,帶隊第一個賽季就幫助米蘭七年后重奪意甲聯賽冠軍,隨后又率隊在北京擊敗國米奪得意大利超級杯,第二個賽季米蘭戰績同樣不錯,可惜在關鍵一戰中因為裁判的誤判失去了一個重要進球,米蘭在聯賽冠軍的爭奪中輸給了尤文圖斯,后面兩個賽季米蘭陣容人員不整,不過阿萊格里還是率隊贏得了上賽季的第三名,從而獲得本賽季歐冠參賽資格。新賽季米蘭戰績比上賽季還差,主帥阿萊格里終于被解職。</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; } </pre><br />
本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!