I'm new to objective c and trying to parse HTML with TFHpple, and having trouble with Xpath.
Currently I'm trying to get news topic from main page of Yahoo Japan. but it return nil.
NSStringEncoding UTF = 4;
NSString *htmlWillInsert = [NSString stringWithContentsOfURL:[NSURL URLWithString:@"http://www.yahoo.co.jp/"] encoding:UTF error:nil];
NSData *htmlData = [htmlWillInsert dataUsingEncoding:NSUnicodeStringEncoding];
TFHpple *xpathParser = [[TFHpple alloc] initWithHTMLData:htmlData];
NSArray *elements = [xpathParser searchWithXPathQuery:@"/html/body/div/div[2]/div[3]/div/div/div[2]/div/div/ul/li/a"];
NSLog(@"%@", elements);
for (TFHppleElement *element in elements)
{
NSLog(@"%@", [element content]);
}
[xpathParser release];
i could get html from yahoo.com . but can't get anything from yahoo JP.
dose any1 know the solution?