简体   繁体   中英

html parsing iPhone sdk?

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

thanks

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.

SDK中包含libxml2.2 ,其中包括libxml/HTMLparser.h ,该文件使用您用来解析XML的API进行HTML 4.0解析。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM