how to Download and save xml in documents and then how to parse xml file from documents?

前端 未结 2 1078
难免孤独
难免孤独 2021-01-01 05:55

In my app app i have to parsing a xml file downloaded from internet. How to download this xml and save in documents on iphone ? and then how can i start the parsing of XML s

2条回答
  •  我在风中等你
    2021-01-01 06:14

    Download the contents to an NSData object when it's loaded for the first time. Save it to disk using either one of

    – writeToFile:atomically:
    – writeToFile:options:error:
    

    Which are described in the NSData class reference here: http://developer.apple.com/mac/library/documentation/Cocoa/Reference/Foundation/Classes/NSData_Class/Reference/Reference.html#//apple_ref/occ/instm/NSData/writeToFile:atomically:

    When you want to load it from disk, use [NSData dataWithContentsOfFile:] to load it into an NSData object again.

    As for parsing NSData into XML, look into other answers to this very, very common question, e.g. How do I parse an NSString containing XML in Objective-C?

提交回复
热议问题