-1

私は辞書を持っていて、それを要素に書くと、次のようになります

<?xml version="1.0" encoding="utf-8"?>
<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>
    <UrunListesi6Response xmlns="http://tempuri.org//Stok">
      <UrunListesi6Result>
        <Urun6>
          <UrunId>int</UrunId>
        </Urun6>
        <Urun6>
          <UrunId>int</UrunId>
        </Urun6>
      </UrunListesi6Result>
    </UrunListesi6Response>
  </soap:Body>
</soap:Envelope>

配列で UrunIds を取得するには、次を使用します

NSMutableArray *a = [[NSMutableArray alloc] init];


a = [[[[[myDictionary  objectForKey:@"soap"]objectForKey:@"UrunListesi6Response" ] objectForKey:@"UrunListesi6Result"] objectForKey:@"Urun6"] objectForKey:@"UrunId"];

NSLog(@"%@",a);

しかし、結果は null です。問題は何ですか?

4

2 に答える 2

1

これは、辞書ではなく、xml ファイルです。

そのxmlをNSDictionaryに読み込んでから試してください。

利用可能な任意の XML パーサーを使用できます。

XML ファイルの解析には多くの回答がありますが、これは今日のみ投稿されたものです。

于 2013-03-02T13:50:24.400 に答える
0

2 つの "soap" キーがあります。

<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>

</soap:Body>
</soap:Envelope>
于 2013-03-02T13:50:05.170 に答える