2

我对“Hpple”有疑问。我正在解析 html 文件,我想获取整个表格,但我得到的结果是 (null)。

我在 Objective-C 中的代码:

-(void)loadTutorials {

    // 1

    paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
    filePath = [NSString stringWithFormat:@"%@/%@", [paths objectAtIndex:0],@"index.html"];

    NSData  *data = [NSData dataWithContentsOfFile:filePath];

    // 2
    TFHpple * doc   = [[TFHpple alloc] initWithHTMLData:data];

    // 3
    NSString *tutorialsXpathQueryString = @"/html/body/div/table/tr/td[@class='bottomwideborder']"; //Next comes the big table

    NSArray *tutorialsNodes = [doc searchWithXPathQuery:tutorialsXpathQueryString];


    for (TFHppleElement *element in tutorialsNodes) {

        table = [element text];

    }

}

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self loadTutorials];

    html = [NSString stringWithFormat:@"<html><body>%@</body></html>", table];

    [Web loadHTMLString:html baseURL:nil];

}

我也想解析的表很长,我认为它对于 NSString 或 NSArray 来说太大了

我能做些什么来解决这个问题?

4

0 回答 0