2013-07-01 76 views
0

我有一个网站,允许用户使用标签嵌入他们的视频,如。在ios中过滤iframe的src属性

<iframe width="560" height="315" src="http://www.youtube.com/embed/se2P7hjPanE" frameborder="0" allowfullscreen></iframe> 

其实这个iframe的字符串是从服务来这样

<br /> 
\n&lt;iframe width=&quot;560&quot; height=&quot;314&#39;&#39; 
    src=&quot;http://www.youtube.com/embed/se2P7hjPanE&quot; frameborder=&quot;0&quot; 
    allowfullscreen&gt;&lt;/iframe&gt; 

我怎样才能得到我原来的iframe字符串如何解析src值,并且可以是其他值实际上我使用的加载视频MWfeedparser(https://github.com/mwaterfall/MWFeedParser),但IAM没有得到这样的

 <iframe width="560" height="314'' src="http://www.youtube.com/embed/se2P7hjPanE" frameborder="0" allowfullscreen></iframe> 

后height属性我得到了(”“),而不是“

我怎样才能解决这个问题

我想从上面的框架得到SRC值我想在iphone的网页流量,以播放视频

让我想打那个特定的视频(其中客户端上传)在我的iPhone。

回答

0

示例代码:

NSString *myString = @"&lt;iframe width=&quot;560&quot; height=&quot;314&#39;&#39; src=&quot;http://www.youtube.com&quot; frameborder=&quot;0&quot; allowfullscreen&gt;&lt;/iframe&gt;"; 
NSRange firstRange = [myString rangeOfString:@"http://"]; 
NSRange secondRange = [[myString substringFromIndex:firstRange.location] rangeOfString:@"&quot;"]; 
NSRange finalRange = NSMakeRange(firstRange.location, secondRange.location); 
NSString *subString = [myString substringWithRange:finalRange]; 
NSLog(@"subString :: %@",subString);