-2

i want convert the follwing string

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

into

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

thank you

siva
  • 251
  • 2
  • 16

2 Answers2

0

It should be done like :-

NSString *HtmlString = @"<iframe width="560" height="314' src="http://www.youtube.com" frameborder="0" allowfullscreen></iframe>";

HtmlString = [HtmlString stringByReplacingOccurrencesOfString:@""" withString:@"\""] ;

Hope this helps .... Please view the edit...

IronManGill
  • 7,222
  • 2
  • 31
  • 52
  • sry i want to keep \ infront of " – siva Jun 29 '13 at 06:35
  • You said you want to convert .... What is ur question exactly please edit accordingly... – IronManGill Jun 29 '13 at 06:36
  • menas i want to place a backward slash infront of all " like in the variables width height src – siva Jun 29 '13 at 06:41
  • if i follwed like this iam getting error bcoz " is not accepting as a string semicolon it self indicates that end of string – siva Jun 29 '13 at 06:49
  • could u plz try above statement iam getting error HtmlString = [HtmlString stringByReplacingOccurrencesOfString:@""" withString:@"\"" – siva Jun 29 '13 at 07:49
0

Answer : MWFeedParser.

There are many methods as shown below. You can use them for your purpose.

  1. - (NSString *)stringByConvertingHTMLToPlainText;
  2. - (NSString *)stringByDecodingHTMLEntities;
  3. - (NSString *)stringByEncodingHTMLEntities;
  4. - (NSString *)stringByEncodingHTMLEntities:(BOOL)isUnicode;
  5. - (NSString *)stringWithNewLinesAsBRs;
  6. - (NSString *)stringByRemovingNewLinesAndWhitespace;

Credit goes to Michael.

Community
  • 1
  • 1
Bhavin
  • 27,155
  • 11
  • 55
  • 94
  • still my vedio is not palying – siva Jun 29 '13 at 07:19
  • @siva : Have you converted the String ? Are you getting the expected conversion result ? Have you used `NSLog` ? – Bhavin Jun 29 '13 at 07:23
  • NSString *videoLink=@"http://www.youtube.com/"; NSString *myHTML = [NSString stringWithFormat:@"\ \ \ \ \ \ ",videoLink]; – siva Jun 29 '13 at 07:31
  • but i need like this to play video i think now u got my problem – siva Jun 29 '13 at 07:32
  • [webView loadHTMLString:myHTML baseURL:nil]; – siva Jun 29 '13 at 07:33
  • @siva: What you asked is all about conversion. I solved your Problem. (For that you should Accept the Answer). Now regarding playing the Video, you should ask a new Question. – Bhavin Jun 29 '13 at 07:39
  • what i asked first only is the same thing placing slashes in front of " – siva Jun 29 '13 at 07:41