Nirav Jain
Nirav Jain

Reputation: 5107

Resolve html properties while parsing

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

Upvotes: 0

Views: 354

Answers (2)

Yorxxx
Yorxxx

Reputation: 526

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;
}

Upvotes: 3

Viktor Apoyan
Viktor Apoyan

Reputation: 10755

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

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

Upvotes: 2

Related Questions