0

I want to parse HTML for my iPhone application. any tuts would help

thanks

Tushar Chutani
  • 1,522
  • 5
  • 27
  • 57

2 Answers2

1
somestring=block of html code

 NSMutableArray *ms=[[NSMutableArray alloc]init];
    NSMutableString *mutable=[NSMutableString new];
    NSScanner *scanner = [NSScanner scannerWithString:someString];
    [scanner setCharactersToBeSkipped:nil];
     NSString *s = nil;
    while (![scanner isAtEnd])
    {
       [scanner scanUpToString:@"<" intoString:&s];
     if (s != nil)
         [ms addObject:s];   
     [scanner scanUpToString:@">" intoString:NULL];
     if (![scanner isAtEnd])
         [scanner setScanLocation:[scanner scanLocation]+1];
     s = nil;
 }
    for(int i=0;i<ms.count;i++)
 {
    [mutable appendFormat:@"%@",[ms objectAtIndex:i]];
 }


//mutable string contains plain text.
Preetam Jadakar
  • 4,479
  • 2
  • 28
  • 58
0

libxml2.2 is in the SDK and includes libxml/HTMLparser.h which does HTML 4.0 parsing using the API you would use to parse XML.

Ternary
  • 2,401
  • 3
  • 31
  • 54