2010-05-09 91 views
0

我在解析XML时遇到问题。 我有一个NSMutablestring currentElementValue,它有新行。它已经作为一个来自网络源的XMl收到。 即使当我试图删除子字符串的前3个字符串的前3个字符时,对字符串没有影响。XML解析时删除换行符

这里可以做些什么? 问候

PC

代码是

(void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { 

if(!currentElementValue) 
    currentElementValue = [[NSMutableString alloc] initWithString:string]; 
else 
{ 
[currentElementValue substringFromIndex:3]; 
[currentElementValue stringByTrimmingCharactersInSet:[NSCharacterSet newlineCharacterSet]]; 

NSLog(@"Processing Value : %@ with length %d", currentElementValue,[currentElementValue length]); 

} 

回答

0

方法stringByTrimmingCharactersInSet:从一开始,只有字符串的结尾去除字符。上一行中的子串调用不会改变任何内容。