在ios中过滤iframe的src属性

时间:2013-07-01 07:40:12

标签: iphone iframe filter 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)但是我没有得到这样的

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

在高度属性后得到('')而不是“

我该如何解决这个问题

我想从帧上方获得src值我想在iphone的webview中播放该视频

所以我想在我的iphone中播放该特定视频(客户端上传的)。

1 个答案:

答案 0 :(得分: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);
相关问题