开发者

How to parse xml file that is encoded with another encoder different from utf-8 with using NSXMLParser in objective-C?

Is there a way to parse xml file that is encoded with windows-1254 with using NSXMLParser? When i try, didStartElement method not called.

Code is

NS开发者_如何学CXMLParser *xmlParser = [[NSXMLParser alloc] initWithData:webData]; 
XMLParser *parser = [[XMLParser alloc] initXMLParser: objectList];
[parser setReqType:reqType]; 
[xmlParser setDelegate:parser]; 
[xmlParser parse]; 

XML is

<?xml version="1.0" encoding="windows-1254" ?> 
 <CANLIMACLAR> 
 <CANLIMACLARROWS> 
<TARIH>19/10/2009 21:15</TARIH> 
<TAKIM1>Union Berlin</TAKIM1> 
<TAKIM2>Fürth</TAKIM2> 
<SONUC1>1</SONUC1> 
<SONUC2>2</SONUC2> 
<DK_DURUM>Maç Sonu</DK_DURUM> ... 
</CANLIMACLARROWS> ...
 </CANLIMACLAR> 


Don't forget if parse() returns NO you can check parseError to see what happened:

if ([parser parse] == NO)
{
   NSError *error = [parser parserError];
   NSString *readableMessage = [error localizedDescription];
   NSLog(@"Error occurred: %@\n", readableMessage);
}


I removed the <?xml version="1.0" encoding="windows-1254" ?> part from xml data and then i send it to xmlParser, so there is no problem anymore.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜