views:

150

answers:

2

Actually I have such a code:

NSString   *path = [[NSBundle mainBundle] pathForResource: @"connect" ofType: @"xml"];
NSError    *error = nil;
NSString   *data = [NSString stringWithContentsOfFile: path 
                                                         encoding: NSUTF8StringEncoding 
                                                            error: &error];
NSString *message = [NSString stringWithFormat:data, KEY, COUNTRY_ID];

which reads the connect.xml from resources. But on the formating the string (message) APP quits without displaying any errors. How can I read connect.xml from resources to NSString with format?

connect.xml looks like this:

<?xml version="1.0" encoding="utf-16"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:WebApi" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&gt;
  <SOAP-ENV:Body>
    <ns1:doQuerySysStatus>
      <sysvar xsi:type="xsd:int">1</sysvar>
      <country-id xsi:type="xsd:int">%d</country-id>
      <webapi-key xsi:type="xsd:string">%@</webapi-key>
    </ns1:doQuerySysStatus>
  </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

And defines:

#define KEY @"f7ff34df7a"
#define COUNTRY_ID 228
+2  A: 

I think on the last line of code, the KEY and COUNTRY_ID variables are backwards.
In the data, COUNTRY_ID is first.

DyingCactus
exactly! I've seen this a sec ago :)
falkon
A: 

Maybe you could try using JSON over XML, it is a much easier format to use.

Jonathan