JSON parsing in iOS and storing the results into Array -


I'm being impotent in iOS, so please bare with a simple question. That's why I am trying to work on the Net Web Service. I am able to get feedback from the web service, the response beow

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Soaps: Envelope xmlns: Soap = "http://schemas.xmlsoap.org/soap/envelope/" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xmlns: xsd = "http : /www.w3.org/2001/XMLSchema"><soap:Body><getDoctorListResponse xmlns = "http://tempuri.org/" & gt; & Lt; GetDoctorListResult & gt; [{"Zone": "Central Northern", "DoctorName": "Dr. Ang Kym Hwi",}, "Junk": "Central", "DoctorName": "Dr. Lee England Seng",}]   

I am only able to get json with the code given below

  - (zero) parser: (NSXMLPerser *) Parser has been found. NSString *) string {if ([current is aquatum string: @ "getDoctorListResult"]) {NSDictionary * dc = (NSDictionary *) string; NSLog (@ "Dictionary is = \ n% @", DC);  

zone: "central answer", "doctor name": " I have examined many similar questions, and I have examined many similar questions, "Dr. Ang Kayam Hovi", {"Zone": "Central", "Doctor Name": "Dr. Lee Angel Seng",}]

There are other similar questions but I could not solve my problem. How can I get the value of the zone and doctor's name and store it in array, In tableview I can Rshit?

you & lt; GetDoctorListResult & gt; needs to collect materials in a frequency variable element, so add the following as a private class extensions

  @interface yourClass () {NSMutableString * _doctorListResultContent; }  

And then XML parser Collect element content using representative:

  - (void) parser: (Ansaksmelpirs *) parser has Thaःstet Element : (NSString *) Element Name Namespace: (NSString *) namespacer qualifiedName: (NSString *) Eligible name attributes: (NSDictionary *) attributeDict {self.currentElement = elementName; If ([Self-revolution is the extolostration: @ "Hold Doklist Result"]) {_doctorListResultContent = [NSMutableString new]; }} - (void) parser: (NSXMLParser *) parser foundCharacters: (NSString *) string {if ([self.currentElement isEqualToString: @ "getDoctorListResult"]) {[_doctorListResultContent appendString: string]; }}  

and finally parse JSON in the end element delegate method:

  - (zero) parser :( NSXMLParser *) parser didEndElement: (NSString *) elementName namespaceURI: (NSString *) namespaceURI qualifiedName: (NSString *) QName {if ([elementName isEqualToString: @ "getDoctorListResult"]) equal to {NSError * error = no; NSDTA * JSNADATA = [_Director ListResultationCommentation using data Encoding: NSUFF 8 string encoding]; ID parse JSON = [NSJSNSRialogeson JSONObjectWithData: jsonData Option: 0 Error: & amp; Error]; If (passagejason) {NSASASRT ([PassageJason Hedundoff Class: [NSARRA class]], @ "Expecting a JSON array";); NSArray * array = (NSArray *) Parsezesen; For (array in NSDictionary * dict) {NSString * zone = dict [@ "zone"]; NSString * doctorName = dict [@ "Doctornames"]; // store in the array and then reload the tableview (reader exercise)} {NSLog (@ "JSON: failed to parse% @", [error localized description]); }}}  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -