-1

i have a dictionary and when i write it's element , it is like

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

To take UrunIds in an array, i use

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


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

NSLog(@"%@",a);

But result is null, what is the problem ?

  • why not use [NSXMLParser](https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.html)? – nsgulliver Mar 02 '13 at 13:51
  • Where do you get myDictionary from? How do you read/write files? – Nikolai Ruhe Mar 02 '13 at 14:29
  • You could use [NSXMLParser](https://developer.apple.com/library/mac/#documentation/Cocoa/Reference/Foundation/Classes/NSXMLParser_Class/Reference/Reference.html) for parsing this kind of data, it will make your life much easier, you can see this [tutorial on NSXMLParser](http://wiki.cs.unh.edu/wiki/index.php/Parsing_XML_data_with_NSXMLParser) – nsgulliver Mar 02 '13 at 13:57

2 Answers2

1

That is a xml file, not a dictionary.

Read that xml into an NSDictionary then try.

You can use any of XML parsers available.

There are a lot of answers for parsing an XML file, this one posted today only.

Community
  • 1
  • 1
Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140
0

There are two "soap" keys:

<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>
Rui Peres
  • 25,741
  • 9
  • 87
  • 137