我遇到了“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来说太大了
我该怎么做才能解决这个问题?