Objective c 从html解析hpple表

Objective c 从html解析hpple表,objective-c,html-table,html-parsing,hpple,Objective C,Html Table,Html Parsing,Hpple,我对“Hpple”有问题。我正在解析html文件,我想得到整个表,但得到的结果是(null) 我在Objective-C中的代码: -(void)loadTutorials { // 1 paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); filePath = [NSString stringWithFormat:@"%@/%@", [path

我对“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];

}
-(无效)加载教程{
// 1
路径=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,是);
filePath=[NSString stringWithFormat:@“%@/%@”,[paths objectAtIndex:0],@“index.html”];
NSData*data=[NSData dataWithContentsOfFile:filePath];
// 2
TFHpple*doc=[[TFHpple alloc]initWithHTMLData:data];
// 3
NSString*tutorialXPathQueryString=@/html/body/div/table/tr/td[@class='bottomwideborder'];//接下来是大表
NSArray*tutorialsNodes=[docsearchwithxpathQuery:tutorialxpathquerystring];
对于(教程节点中的TFHPPLEEMENT*元素){
表=[元素文本];
}
}
-(无效)viewDidLoad
{
[超级视图下载];
[自学教程];
html=[NSString stringWithFormat:@“%@”,表];
[Web loadHTMLString:html baseURL:nil];
}
我想要解析的表太长了,我认为它对于NSString或NSArray来说太大了


如何解决此问题?

ivar表在哪里初始化,它是什么类型的对象?如果它是一个数组,并且您试图在表数组中保存[element text],那么您不会添加元素文本。谢谢,我尝试修复它)