2013-05-30 36 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