开发者

Resolve html properties while parsing

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜