2013-05-30 35 views
0

我有一個靜態數組like.Here它是靜態數組。我想從Web服務加載。 如如何從Web服務加載數組?

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

     tableData = [NSArray arrayWithObjects:@"Egg Benedict", @"Mushroom Risotto", 
      @"Pig spit-roast", @"goat", @"beefed up beef", @"squidles", 
      @"whale", @"crabbies", @"quack", @"Instant Noodle with Egg", 
      @"Noodle with BBQ Pork", @"Japanese Noodle with Pork", 
      @"Green Tea", @"Thai Shrimp Cake", @"Angry Birds Cake", 
      @"Ham and Cheese Panini", nil]; 

     } 

我想從服務中加載所有食品一樣,

 NSString *soapMessage =[NSString stringWithFormat: 

     @"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" 
"<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"  
     xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" 
     xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">" 
"<soap:Body>" 
"<List xmlns=\"http://tempuri.org/\">" 
"<Foods></Foods>" 

"</List>" 
"</soap:Body>" 
"</soap:Envelope>"        
]; 
+0

這裏有兩個問題。解析soap響應並將XML轉換爲項目數組。你是否善於分析肥皂? – bbarnhart

+0

是的,我可以解析。只有我不知道從Web服務加載數組 – Mhmt

+0

你想使用第三方XML解析器還是Apple的XML解析器? – bbarnhart

回答

2

使用此XML解析庫:TBXML

然後按照解析這個逐步教程:xml-parsing-using-tbxml

希望它可以幫助你。

+0

很好的例子,但我的服務格式是soap – Mhmt

+1

你可以使用TBXML來解析它。我已經多次使用TBXML解析SOAP。 –

+0

我的問題是:我知道從肥皂中加載任何標籤,textfields,我知道肥皂解析,但我不知道從同一個肥皂服務加載數組:) – Mhmt