2016-05-09 8 views
-2

JSON webserviceからの応答があり、 "name"というノードが1つあります。htmlノードとの間の文字列の読み込み方法

{ 
    "name": "<style>b\n {\n font-family:'helvetica';\n line-height: 200%;\n text-align: justify;\n } \n </style><b>CORN IDLIS</b><br/>" 
} 

私はコーンIDLISの間で食品名を取得しようとしています。

このノードからすべてのhtmlタグを読み込みまたは削除する方法を教えてください。

+0

あなたのhtmlでJSONデータを解析するか、単にhtmlコードの削除についてあなたの問題ですか? 2番目のもの:http://stackoverflow.com/questions/23757655/how-to-remove-html-tags-from-nsstring-in-iphone? – Larme

答えて

0

適切にコードの下の作業、htmlstringは

NSAttributedString *tmp =[[NSAttributedString alloc] initWithData:[htmlstring dataUsingEncoding:NSUTF8StringEncoding] options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType, NSCharacterEncodingDocumentAttribute: [NSNumber numberWithInt:NSUTF8StringEncoding]} documentAttributes:nil error:nil]; 
0

あなたの文字列を取得することができ

NSString *htmlStr = responseDic[@"name"]; 
NSArray *tempArray = [htmlStr componentsSeparatedByString:@"<b>"]; 
NSArray *tempArray1 = [tempArray[1] componentsSeparatedByString:@"</b>"]; 
NSString *yourString = [tempArray1 firstObject]; 
関連する問題