ios - Converting plist object to XML embeded in NSString -


i want send plist object email in xml test format.

what kind of code (preferably simple) should write after one:

nsstring *xmlstring; nsdictionary *borrowed = @{@"reader": @"ryan shaw",                            @"books":  @[ @{@"title":  @"the godfather",                                            @"author": @"mario puzo",                                            @"date":   @"2014-04-08t13:36:33z"},                                          @{@"title":  @"adventures of huckleberry finn",                                            @"author": @"mark twain",                                            @"date":   @"2014-04-08t13:36:33z"} ]                          }; 

to have in result xmlstring contain following value:

@"<dict>     <key>reader</key>     <string>ryan shaw</string>     <key>books</key>     <array>         <dict>             <key>title</key>             <string>the godfather</string>             <key>author</key>             <string>mario puzo</string>             <key>date</key>             <date>2014-04-08t13:36:33z</date>         </dict>         <dict>             <key>title</key>             <string>adventures of huckleberry finn</string>             <key>author</key>             <string>mark twain</string>             <key>date</key>             <date>2014-04-08t13:36:33z</date>         </dict>     </array> </dict>" 

is there ios framework able this, or should write parser myself or use third party library?

the missing code follows:

    nserror *error;     nsdata *xmldata = [nspropertylistserialization datawithpropertylist:borrowed                                                                  format:nspropertylistxmlformat_v1_0                                                                 options:0                                                                   error:&error];     if ( !error )         xmlstring = [[nsstring alloc] initwithdata:xmldata encoding:nsutf8stringencoding]; 

there no need special framework linked in.


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -