开发者

Resolve html properties while parsing

开发者 https://www.devze.com 2023-02-28 19:20 出处:网络
How can I remove HTML entities from parsing XML?? Means i am parsing XML but 开发者_C百科I\'m not able to remove <br/>, &nbsp; etc. You mean something like this?

How can I remove HTML entities from parsing XML?? Means i am parsing XML but 开发者_C百科I'm not able to remove <br/>, &nbsp; etc.


You mean something like this?

   /**
 * Removes the HTML tags found in the string
 * @param html the string to scan
 *
 * @returns the original string without tags
 */
- (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
    html = [html stringByReplacingOccurrencesOfString:
            [NSString stringWithFormat:@"%@>", text]
                                           withString:@" "];
  } // while //

  return html;
}


[NSString stringByReplacingOccurrencesOfString:@","withString:@""];

Try to use this function, replace symbols witch you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消