-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (nsdictionary *) launchOptions{ [self test]; //Override point for customization after application Launch. return YES;} -(void) Test { //xml Text Example nsstring * testxmlstring = @ "Cake0.55regularchocolateblueberrynoneglazedsugar"; nslog (@ "XML string[\n%@\n]", testxmlstring); //parsing XML is nsdictionary nserror *parseerror = nil; nsdictionary *xmldictionary = [XMLReader dictionaryforxmlstring:testxmlstring error:&parseerror]; //Print NSDictionary nslog (@ "%@", xmldictionary); // Nsdictionary conversion to data nsdata* jsondata = [Nsjsonserialization datawithjsonObject:xmlDictionaryoptions:NSJSONWritingPrettyPrinted error:&parseerror]; //data conversion to json nsstring* str = [[NSString alloc] Initwithdata:jsondata Encoding:nsutf8stringencoding]; nslog (@ "JsonData string[\n%@\n]" , str); //character Group converted to nsdictionary nsdictionary *jsondict = [str Objectfromjsonstring]; //nsdictionary Convert to XML plist format nsdata *xmldata = [Nspropertylistserialization datafrompropertylist:jsondict format:nspropertylistxmlformat_v1_0 errorDescription:NULL]; The //data is converted to a nsstring output encoding of Utf-8 nslog (@ "XML:%@", [[NSString Alloc] Initwithdata:xmldata encoding:nsutf8stringencoding]); nslog (@ "%@", [XMLWriter xmlstringfromdictionary:jsondict WithHeader:NO] } //, which uses three class libraries, respectively, for the 1,jsonkit https://github.com/johnezang/ Jsonkit2,xmlwriter https://github.com/ahmyi/xmlwriter3,xmlreader https:// Github.com/amarcadet/xmlreader&nBSP; source:http://download.csdn.net/download/p709723778/5725585 The following connection is XML converted to dictionaryhttps://github.com /nicklockwood/xmldictionaryhttp://download.csdn.net/detail/p709723778/6706331
iOS Development----Nsdictionary,json and XML conversions