2010-05-09 75 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:從一開始,只有字符串的結尾去除字符。上一行中的子串調用不會改變任何內容。