Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/44.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
删除iphone SDK中的特定HTML标记_Iphone_Html_Ios_Xcode_Html Parsing - Fatal编程技术网

删除iphone SDK中的特定HTML标记

删除iphone SDK中的特定HTML标记,iphone,html,ios,xcode,html-parsing,Iphone,Html,Ios,Xcode,Html Parsing,我有一个NSString,其中包含HTML内容。但是我想从NSString中删除标记 e、 g //像下面这样做…让我知道它是否工作 -(void)viewWillAppear:(BOOL)animated { source = [NSString stringWithFormat:@"%@",[[self.parseResults objectAtIndex:k] objectForKey:@"summary"]]; Source=[self flattenHTML:Source];//c

我有一个
NSString
,其中包含
HTML
内容。但是我想从NSString中删除标记

e、 g


//像下面这样做…让我知道它是否工作

-(void)viewWillAppear:(BOOL)animated
{
 source = [NSString stringWithFormat:@"%@",[[self.parseResults objectAtIndex:k] objectForKey:@"summary"]];
 Source=[self flattenHTML:Source];//call flattenhtml method...
 NSLog(@"%@",source);
}


#pragma mark ---Removing HTML Tags
- (NSString *)flattenHTML:(NSString *)html {

NSScanner *theScanner;
NSString *text = nil;
theScanner = [NSScanner scannerWithString:html];

while ([theScanner isAtEnd] == NO) {

    [theScanner scanUpToString:@"<" intoString:NULL] ; 

    [theScanner scanUpToString:@">" intoString:&text] ;

}
html = [html stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

return html;
}
-(void)视图将显示:(BOOL)动画
{
source=[NSString stringWithFormat:@“%@”,[[self.parseResults objectAtIndex:k]objectForKey:@“summary”];
Source=[self-flattHTML:Source];//调用flattHTML方法。。。
NSLog(@“%@”,来源);
}
#pragma标记---删除HTML标记
-(NSString*)html:(NSString*)html{
NSScanner*扫描仪;
NSString*text=nil;
扫描仪=[NSScanner SCANNER WITHSTRING:html];
while([扫描仪显示]==否){
[扫描程序扫描字符串:@“intoString:&text];
}
html=[html stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
返回html;
}

//像下面这样做……让我知道它是否工作

-(void)viewWillAppear:(BOOL)animated
{
 source = [NSString stringWithFormat:@"%@",[[self.parseResults objectAtIndex:k] objectForKey:@"summary"]];
 Source=[self flattenHTML:Source];//call flattenhtml method...
 NSLog(@"%@",source);
}


#pragma mark ---Removing HTML Tags
- (NSString *)flattenHTML:(NSString *)html {

NSScanner *theScanner;
NSString *text = nil;
theScanner = [NSScanner scannerWithString:html];

while ([theScanner isAtEnd] == NO) {

    [theScanner scanUpToString:@"<" intoString:NULL] ; 

    [theScanner scanUpToString:@">" intoString:&text] ;

}
html = [html stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

return html;
}
-(void)视图将显示:(BOOL)动画
{
source=[NSString stringWithFormat:@“%@”,[[self.parseResults objectAtIndex:k]objectForKey:@“summary”];
Source=[self-flattHTML:Source];//调用flattHTML方法。。。
NSLog(@“%@”,来源);
}
#pragma标记---删除HTML标记
-(NSString*)html:(NSString*)html{
NSScanner*扫描仪;
NSString*text=nil;
扫描仪=[NSScanner SCANNER WITHSTRING:html];
while([扫描仪显示]==否){
[扫描程序扫描字符串:@“intoString:&text];
}
html=[html stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
返回html;
}

我通过将HTML转换为字符串解决了这个问题

只需导入两个文件NSString+HTML.h&NSString+HTML.m文件


然后调用
text\u str=[html\u str stringByConvertingHTMLToPlainText]

我通过将HTML转换为字符串解决了这个问题

只需导入两个文件NSString+HTML.h&NSString+HTML.m文件


然后调用
text\u str=[html\u str stringByConvertingHTMLToPlainText]

我不是在告诉你你错了,我的朋友,但它应该有效,代码在我的每个应用程序中都有效…我不是在告诉你你错了,我的朋友,但它应该有效,代码在我的每个应用程序中都有效。。。
-(void)viewWillAppear:(BOOL)animated
{
 source = [NSString stringWithFormat:@"%@",[[self.parseResults objectAtIndex:k] objectForKey:@"summary"]];
 Source=[self flattenHTML:Source];//call flattenhtml method...
 NSLog(@"%@",source);
}


#pragma mark ---Removing HTML Tags
- (NSString *)flattenHTML:(NSString *)html {

NSScanner *theScanner;
NSString *text = nil;
theScanner = [NSScanner scannerWithString:html];

while ([theScanner isAtEnd] == NO) {

    [theScanner scanUpToString:@"<" intoString:NULL] ; 

    [theScanner scanUpToString:@">" intoString:&text] ;

}
html = [html stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];

return html;
}