2
我试图使用iPhone上的Xpath从here中提取天气信息。到目前为止,它解析所有的数据,但我坚持如何提取内容并将其显示在表格中。 这是我到目前为止有:如何在iPhone上显示Xpath
NSData *data = [NSData dataWithContentsOfURL:[NSURL URLWithString:[ @"http://aviationweather.gov/adds/metars/?station_ids=1234&std_trans=translated&chk_metars=on&hoursStr=most+recent+only&submitmet=Submit"stringByReplacingOccurrencesOfString:@"1234" withString:self.title]]];
TFHpple * doc = [[TFHpple alloc] initWithHTMLData:data];
NSArray * elements = [doc searchWithXPathQuery:@"//table[1]//tr"];
NSLog(@"%@", elements);
TFHppleElement * element = [elements objectAtIndex:0];
[element content]; // Tag's innerHTML
[element tagName]; // "a"
[element attributes]; // NSDictionary of href, class, id, etc.
[element objectForKey:@"href"]; // Easy access to single attribute
如果有人需要看看它的输出到目前为止,让我知道。
感谢, 安德鲁
在Google上查看“UITableView教程”,例如, http://www.google.com/search?client=safari&rls=zh-CN&q=uitableview+tutorial&ie=UTF-8&oe=UTF-8 – 2012-01-13 21:11:50
它不是显示我不明白的表格,它组织数据以便我可以显示它。谢谢 – Boos1993 2012-01-13 21:16:05
我想我不明白。你想展示什么数据?如果你可以把你的数据放到一个数组中,那么你可以把它放到一个表中。看起来你已经在'elements'中有了这个数组,这只是一个循环遍历数组来制作表格单元的问题。 – 2012-01-13 21:29:03