Tushar Chutani
Tushar Chutani

Reputation: 1570

html parsing iPhone sdk?

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

thanks

Upvotes: 0

Views: 950

Answers (2)

Preetam Jadakar
Preetam Jadakar

Reputation: 4561

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.

Upvotes: 1

Ternary
Ternary

Reputation: 2421

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.

Upvotes: 0

Related Questions