2011-02-03 3 views
0

대신의 URL에서 XML을로드, 나는로드 XML - 아이폰

NSString* [email protected]"magzine.xml"; 
NSData *data=[NSData dataWithContentsOfURL:[[NSURL alloc] initWithString:[URLlink stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]]; 
NSString *applicationDocumentsDir =[NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) lastObject]; 
NSString *storePath = [applicationDocumentsDir stringByAppendingPathComponent:filename]; 
[data writeToFile:storePath atomically:YES]; 
NSLog(@"URL: %@",url); 
xmlParser = [[NSXMLParser alloc] initWithContentsOfURL:url]; 
//xmlParser = [[NSXMLParser alloc] initWithContentsOfFile:filename]; 

[xmlParser setDelegate:self]; 
[xmlParser parse]; 

지금 내가 무엇입니까 (인터넷 연결이있을 때 내가 저장 한) 문서 디렉토리에서로드 싶습니다 url에서 xml, 즉 initwithcontentsofurl에서입니다. 이제는 인터넷에 연결되어 있지 않을 때 문서 디렉토리에서 저장된 파일을 가져오고 싶습니다. XML을로드하는 방법을 알려주십시오. 미리 감사드립니다.

답변

0

Here은 iPhone에서 로컬 XML 파일을로드하고 구문 분석하는 방법에 대한 예입니다.