Note that there are some explanatory texts on larger screens.

plurals
  1. PONSDictionary to XML
    primarykey
    data
    text
    <p>I'm trying to convert a NSDictionary to XML. (I was successful in transforming NSDictionary to JSON). But now I need to transform NSDictionary to XML. Is there a built-in serializer in Objective-C like the one for JSON?</p> <pre><code>int r = arc4random() % 999999999; //simulate my NSDictionary (to be turned into xml) NSString *name = [NSString stringWithFormat:@"Posted using iPhone_%d", r]; NSString *stock_no = [NSString stringWithFormat:@"2342_%d", r]; NSString *retail_price = @"12345"; NSArray *keys = [NSArray arrayWithObjects:@"name", @"stock_no", @"retail_price", nil]; NSArray *objects = [NSArray arrayWithObjects:name,stock_no,retail_price, nil]; NSDictionary *theRequestDictionary = [NSDictionary dictionaryWithObjects:objects forKeys:keys]; NSDictionary *theFinalRequestDictionary = [NSDictionary dictionaryWithObject:theRequestDictionary forKey:@"product"]; </code></pre> <p>...//other irrelevant code omitted</p> <pre><code>NSData *theBodyData = [NSPropertyListSerialization dataFromPropertyList:theFinalRequestDictionary format:NSPropertyListXMLFormat_v1_0 errorDescription:nil]; NSPropertyListFormat format; id XMLed = [NSPropertyListSerialization propertyListFromData:theBodyData mutabilityOption:NSPropertyListImmutable format:&amp;format errorDescription:nil]; NSLog(@"the XMLed is this: %@", [NSString stringWithFormat:@"%@", XMLed]); </code></pre> <p>The NSLog doesn't print a string in XML format. It prints it like a NSDictionary. What should I use to serialize my NSDictionary to XML?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload