2011-04-22 3 views
0

과 같은 기호로 올바로 작동하지 않습니다. 내 iPhone 응용 프로그램에서 XML 구문 분석에 몇 가지 문제가 있습니다. 다음은 표준 NSXMLParser 파서로 구문 분석 할 XML 코드의 일부입니다.NSXMLParser가 "

<item> 
<title>AMNews: Facebook & Twitter Updates Might Lead To Burglary, Oldham School Violates DPA, Amazon Cloud “Burstsâ€</title> 
<link>http://www.itproportal.com/2011/04/22/amnews-facebook-twitter-updates-might-lead-to-burglary-oldham-school-violates-dpa-amazon-cloud-bursts/</link> 
<description>People announcing their holiday plans on social networking platforms like Facebook and Twitter are putting themselves at risks from thieves and burglars. A new study ha</description> 
<author>[email protected] (Ravi Mandalia)</author> 
<pubDate>Fri, 22 Apr 2011 08:19:36 +0100</pubDate> 
<guid>http://cdn.itproportal.com/photos/facebook-logo-4_thumb80x80.png</guid> 
</item> 

당신이

<title>AMNews: Facebook & Twitter Updates Might Lead To Burglary, Oldham School Violates DPA, Amazon Cloud “Burstsâ€</title> 

제목 태그에 이상한 기호는 "â € œ" "â"표시 볼 수있는 방법. 함수 내

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string; 

제목을 가져 와서 저장하려고하지만 파서가 잘못 작동합니다. 파서는 "" "기호 뒤에 텍스트 만 가져옵니다 !!!

내가 할 수있는 일은 무엇이며 누구에게 구문 분석이 어떻게되는지 말해 줄 수 있습니까? 고마워요 !!!

답변

0

내가 마지막에 €의 œ에서 â의 €의 œ와 두 번째로 시작에서 해당 파서 GET 타이틀을 처음으로 두 번 알이 -parser:foundCharacters:

- (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { 
    //in case of unusable tags 
    if (currentArticle == nil) { 
     return; 
    } 
    // Get Title. 
    if ([currentElement isEqualToString:@"title"]) { 
     [self.currentArticle setTheTitle:string]; 
    // Get Description. 
    } else if ([currentElement isEqualToString:@"description"]) { 
     string = [string stringByReplacingOccurrencesOfString: @"\n" withString: @"" ]; 
     [self.currentArticle setTheSummary:string]; 

    } else if ([currentElement isEqualToString:@"link"]) { 
     [self.currentArticle setTheMainLink:string]; 

    } else if([currentElement isEqualToString:@"guid"]){ 
     [self.currentArticle setTheImageLink:string]; 

    } else if ([currentElement isEqualToString:@"pubDate"]) { 
     [self.currentArticle setThePubDate:string]; 

    } else if([currentElement isEqualToString:@"author"]){ 
     [self.currentArticle setTheAuthor:string]; 
    } 
} 

의 구현입니다. 내 피드처럼 두 제목 태그가 있습니다.

1

-parser:foundCharacters:의 구현을 보여줄 수 있습니까? 어떻게 보관합니까 ?

나는 XML 파일에 특수 문자가있는 NSXMLParser을 한 번 사용했으며 문제없이 작동했습니다. 여기

+0

아이디어가 있습니까 ??? –