xml解析链接有子标记作为链接,在此链接中有描述和图像和标题。我想得到描述部分然后我为那个
写了一个代码- (void)loadingDescription
{
NSError *error=nil;
//* goshipsUrl has link and send to the nsdata*
NSData *gossipshtmldata=[NSData dataWithContentsOfURL: gossipsUrl options:NSDataReadingUncached error:&error];
// i am using the nserrer for which one is error,we need to find out but it gives no exceptions and nil value
if (error) {
NSLog(@"%@",[error localizedDescription]);
}
else {
NSLog(@"loading successfully");
}
TFHpple *gossipsParser = [TFHpple hppleWithHTMLData:gossipshtmldata];
NSString *gossipsXpathQueryString = @"//p//text()";
NSLog(@"%@",gossipsParser);//it has the object
descriptionGossipsNodes = [gossipsParser searchWithXPathQuery:gossipsXpathQueryString];
//in descriptionGossipsNodes has only 6 objects
if ([descriptionGossipsNodes count] > 0)
{
[self.emailButton setEnabled:YES];
[self.twitterButton setEnabled:YES];
[self.facebookButton setEnabled:YES];
[scrollview setHidden:NO];
NSMutableArray *tempArray = [NSMutableArray array];
for (TFHppleElement *element in descriptionGossipsNodes)
{
[tempArray addObject:[element content]];
}
//in temparary array has only <__NSArrayM 0x7f87e8dd1820>( , Contact us, , Privacy, © 2015,) this content.
NSString *result = [tempArray componentsJoinedByString:@""];
self.textview.text = result;
}
else
{
[self.emailButton setEnabled:NO];
[self.twitterButton setEnabled:NO];
[self.facebookButton setEnabled:NO];
[scrollview setHidden:YES];
UIAlertView *alert =[[UIAlertView alloc]initWithTitle:@"Connection Failed" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alert show];
}
}
所以如何解决我在评论中解释的代码。