I am trying to parse the below link using hpple:
http://www.decanter.com/news/wine-news/529748/mimimum-pricing-opponents-slam-cameron-speech
Code:
- (void)parseURL:(NSURL *)url {
NSData *htmlData = [NSData dataWithContentsOfURL:url];
TFHpple *xpathParser = [[TFHpple alloc] initWithHTMLData:htmlData];
NSArray *elements = [xpathParser searchWithXPathQuery:@"<div class="body" id="article-529748-body">"];
NSLog(@"elements %@",elements);
TFHppleElement *element = [elements objectAtIndex:0];
NSString *myTitle = [element content];
[xpathParser release];
}
but it is crashing. Crash Report:
XPath error : Invalid expression
<div class="body" id="article-529748-body">
^
XPath error : Invalid expression
<div class="body" id="article-529748-body">
^
How to solve this issue? why my elements array is empty? Am I parsing in a wrong way? I want to get the information available in that div tag.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…