javascript - strip html tags from data in ios -


i have app has admin end on web , user end on ios. in web end have placed tinymce editor allows admin enter text in paragraphs , list view. data getting entered in database having html tags, in webservice getting data(that entered admin end) in json format along getting html tags also.

part of data getting in json format looks this

{   "list":[{"id":"1","state_info":"<p class=\"grid-para\" style=\"box-sizing: border-box; margin: 0px; font-size: 1.1em; line-height: 1.7em; padding: 1em 0px 0px; font-family: \'open sans\', sans-serif;\" align=\"justify\">abc...some text &amp;</p>n<p style=\"box-sizing: border-box; margin: 0px; color: #333333; font-family: \'open sans\', sans-serif; font-size: 14px; line-height: 20px;\"><strong style=\"box-sizing: border-box;\">abc...some text.</strong></p>n<p style=\"box-sizing: border-box; margin: 0px; color: #333333; font-family: \'open sans\', sans-serif; font-size: 14px; line-height: 20px;\">abc...some text"}] } 

part of code tried is

       @implementation nsstring (striphtml) -(nsstring*)striphtml {     nsstring* string = [self stringbyreplacingoccurrencesofstring:@"<p=%@&</p=%@" withstring:@""];     string = [nsstring stringwithformat:@"<root>%@</root>", string];       nsstringencoding encoding = string.fastestencoding;     nsdata* data = [string datausingencoding:encoding];     nsxmlparser* parser = [[nsxmlparser alloc] initwithdata:data];      nsstring_striphtml_xmlparsee* parsee = [[nsstring_striphtml_xmlparsee alloc] init];     parser.delegate = parsee;     [parser parse];       nsstring* strippedstring = [parsee getcharsfound];      [parser release];     [parsee release];      return strippedstring; } 

i have tried use many editors getting tags editors , if don't use editor data single paragraph.

can please tell how remove these tags without removing effect. or maybe way can enter data in paragraph , list view without tags

does work you?

- (nsstring *)striphtml{     nserror *error = nil;     nsattributedstring *attributedstring = [[nsattributedstring alloc] initwithdata:[self datausingencoding:nsutf8stringencoding]                                                                             options:@{nscharacterencodingdocumentattribute:@(nsutf8stringencoding),                                                                                       nsdocumenttypedocumentattribute: nshtmltextdocumenttype}                                                                  documentattributes:nil                                                                               error:&error];     if(error){         nslog(@"error %@",[error localizeddescription]);     }      return [attributedstring string];  } 

Comments