如何从iOS上的解析文本中删除HTML标记?
问题描述:
我正在解析一个文本并将它存储在一个NSString变量中。但是,当我尝试在屏幕上显示NSString时,我可以在文本中看到如下标签:< br>
。如何从我的文本中删除这些标签并将其替换为空格或其他内容?
I am parsing a text and store it in a NSString variable. However when I try to display the NSString on screen I can see, within the text, the html tags like: <br>
. How can I remove this tags from my text and replace them with a space or something?
答
NSString *str = @"This is<br>a string";
str = [str stringByReplacingOccurrencesOfString:@"<br>" withString:@""];