iOS获取HTML标题标记

时间:2013-02-03 01:57:20

标签: iphone html ios uiwebview hpple

我正在尝试获取HTML的标题标记,并使用Hpple来解析HTML。出于某种原因,当我使用此代码

时,我将变为null
    NSURL *Url = self.webview.request.URL;
NSData *HtmlData = [NSData dataWithContentsOfURL:Url];
TFHpple *Parser = [TFHpple hppleWithHTMLData:HtmlData];
NSString *XpathQueryString = @"//head/title";
NSArray *Nodes = [Parser searchWithXPathQuery:XpathQueryString];
self.textfield.text = [NSString stringWithFormat:@"%@|%@", [[[[Nodes objectAtIndex:0] objectForKey:@"nodeChildArray"] objectAtIndex:0] objectForKey:@"nodeContent"], [Url absoluteString]];

当我记录数组[Nodes objectAtIndex:0]时,我得到了

{
 nodeChildArray =     (
            {
        nodeContent = Google;
        nodeName = text;
    }
);
nodeName = title;
}

0 个答案:

没有答案