基本上我需要从这个html文件中解析td(表数据)。我需要得到正确的xpath。我使用raywenderlich作为这个任务的模型,这是我到目前为止的代码。
NSURL *tutorialsUrl = [NSURL URLWithString:@"http://example.com/events];
NSData *tutorialsHtmlData = [NSData dataWithContentsOfURL:tutorialsUrl];
// 2
TFHpple *tutorialsParser = [TFHpple hppleWithHTMLData:tutorialsHtmlData];
// 3
NSString *tutorialsXpathQueryString = @"This is where I need to enter my xpath to rerieve the table data";
NSArray *tutorialsNodes = [tutorialsParser searchWithXPathQuery:tutorialsXpathQueryString];
感谢firebug,我有这个元素的html路径,我将在下面发布。
/<html lang="en">/<body>/div id="page" class="container">/<div class="span-19">/<div id="content">/<div>/<table id=yw0 class="detail-view">/<tbody>/<tr class="even">/<td>moo</td>/
我需要解析文本 moo。任何帮助将不胜感激。
这也是我从 firebug 获得的 x 路径,但它根本不起作用。
/html/body/div/div[4]/div/div/table/tbody/tr[2]/td