Reputation: 1336
I am doing JSON parsing. There are many different substrings in response which I want to remove, because HTML or ASCII values comes in my response. Like '
or $quot;
or &
etc.
I am using following method for remove substring, but how I can remove all ASCII or HTML substrings ?
NSString *strTe=[strippedString
stringByReplacingOccurrencesOfString:@"' ;" withString:@""];
Edit: Look this page under the HTML Table Heading, I got these symbols in my response.
Upvotes: 0
Views: 1436
Reputation: 3274
This code may help your query :
- (NSString *)flattenHTML:(NSString *)html
{
NSScanner *theScanner;
NSString *text = nil;
theScanner = [NSScanner scannerWithString:html];
while ([theScanner isAtEnd] == NO)
{
[theScanner scanUpToString:@"<" intoString:NULL] ;
[theScanner scanUpToString:@">" intoString:&text] ;
html = [html stringByReplacingOccurrencesOfString:[NSString stringWithFormat:@"%@>", text] withString:@""];
}
html = [html stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
return html;
}
Upvotes: 1