2010-10-22 105 views
1

早上好每一個,解析本地保存的XML文件

我已經donloaded XML文件到我的文檔文件夾,但我怎麼能確定的路徑文件,所以我可以解析它?!?

NSString *rootPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0]; 
NSString *localPath = [rootPath stringByAppendingPathComponent:@"test.xml"]; 

tryed它,我得到這個mesage:

/.../.../Library/Application Support/iPhone Simulator/4.0/Applications/AF71BAFD-2014-4A79-BEA8-D6D9D2A6BBDB/Documents/test.xml 
Entity: line 1: parser error : Start tag expected, '<' not found 
/.../.../Library/Application Support/iPhone Simulator/4.0/Applications/ 

的XML文件是正確的格式,因爲我可以不從服務器上的任何問題解析 誰能幫助我和那個?!?

回答

1

開始登錄使用本地文件的內容:

NSLog(@"Local xml: %@", [NSString stringWithContentsOfFile:localPath 
                encoding:NSUFT8StringEncoding 
                error:NULL]); 

只是爲了驗證本地內容實際上是正確的。在服務器上糾正並不能保證在客戶端路徑上沒有錯誤。

+0

感謝您的提示,它只是讓我在正確的方向我忘了編碼,現在它的工作.... – zim 2010-10-27 07:29:40