2011-03-07 92 views

回答

0

libxml2.2是在SDK包括libxml/HTMLparser.h它不使用你會用它來解析XML的API HTML 4.0的解析。

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.