2011-08-30 72 views
0

值这是一个后续我刚才的问题:Extracting an href's text from an html document提取从HTML HREF的属性

我怎样才能在seekVideo(number)多少?例如:

<a href="#" class="transcriptLink" onclick="seekVideo(2000); return false;" 

我想要“2000”。

我曾尝试:

NSArray *elements = [xpathParser search:@"//div[@id='transcriptText']/div/p/number(substring-before(substring-after(@onclick, '('), ')'))"]; 

但是,这是不对的。我怎样才能做到这一点?

如果有人可以使用Kirill Polishchuk在此Web提供的代码框架(https://stackoverflow.com/questions/6723244/iphone-how-to-select-this-label),那就太棒了。

+0

可能重复? ](http://stackoverflow.com/questions/7231132/iphone-how-to-get-this-label) – Mat

回答

0

您可以使用NSScanner:

int seekVideo = 0; 
NSString *testString = @"<a href=\"#\" class=\"transcriptLink\" onclick=\"seekVideo(2000); return false;\""; 

NSScanner *scanner = [NSScanner scannerWithString:testString]; 
[scanner scanUpToString:@"seekVideo(" intoString:nil]; 
[scanner scanString:@"seekVideo(" intoString:nil]; 
[scanner scanInt:&seekVideo]; 

NSLog(@"seekVideo: %d", seekVideo); 

2011-08-30 07:47:11.504测试[56342:707] seekVideo:2000 [iphone,如何让这个标签的