Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6373037
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T01:18:51+00:00 2026-05-25T01:18:51+00:00

i am using NSPropertyListSerialization for converting nsdictionary to xml and the code is as

  • 0

i am using NSPropertyListSerialization for converting nsdictionary to xml and the code is as follows

NSMutableDictionary *rootObj = [NSMutableDictionary dictionaryWithCapacity:2];
    NSDictionary *innerDict;
    NSString *name;
    NSDate *dob;
    NSArray *scores;

    scores = [NSArray arrayWithObjects:[NSNumber numberWithInt:6],
              [NSNumber numberWithFloat:4.6], [NSNumber numberWithLong:6.0000034], nil];
    name = @"George Washington";
    dob = [NSDate dateWithString:@"1732-02-17 04:32:00 +0300"];
    innerDict = [NSDictionary dictionaryWithObjects:
                 [NSArray arrayWithObjects: name, dob, scores, nil]
                                            forKeys:[NSArray arrayWithObjects:@"Name", @"DOB", @"Scores"]];
    [rootObj setObject:innerDict forKey:@"Washington"];

    scores = [NSArray arrayWithObjects:[NSNumber numberWithInt:8],
              [NSNumber numberWithFloat:4.9],
              [NSNumber numberWithLong:9.003433], nil];
    name = @"Abraham Lincoln";
    dob = [NSDate dateWithString:@"1809-02-12 13:18:00 +0400"];
    innerDict = [NSDictionary dictionaryWithObjects:
                 [NSArray arrayWithObjects: name, dob, scores, nil]
                                            forKeys:[NSArray arrayWithObjects:@"Name", @"DOB", @"Scores"]];
    [rootObj setObject:innerDict forKey:@"Lincoln"];


    NSLog(@"the dictionary is :%@",rootObj);


    id plist = [NSPropertyListSerialization dataFromPropertyList:(id)rootObj
                                                          format:NSPropertyListXMLFormat_v1_0 errorDescription:nil];

NSLog(@ "the xml file is :%@",plist);

and the out put in console is as follows……

XmltoNSDictionary[2478:207] the dictionary is :{
    Lincoln =     {
        DOB = "1809-02-12 09:18:00 +0000";
        Name = "Abraham Lincoln";
        Scores =         (
            8,
            "4.9",
            9
        );
    };
    Washington =     {
        DOB = "1732-02-17 01:32:00 +0000";
        Name = "George Washington";
        Scores =         (
            6,
            "4.6",
            6
        );
    };
}

2011-08-22 11:35:09.611 XmltoNSDictionary[2478:207] the xml file is
:<3c3f786d 6c207665 7273696f 6e3d2231 2e302220 656e636f 64696e67
3d225554 462d3822 3f3e0a3c 21444f43 54595045 20706c69 73742050
55424c49 4320222d 2f2f4170 706c652f 2f445444 20504c49 53542031
2e302f2f 454e2220 22687474 703a2f2f 7777772e 6170706c 652e636f
6d2f4454 44732f50 726f7065 7274794c 6973742d 312e302e 64746422
3e0a3c70 6c697374 20766572 73696f6e 3d22312e 30223e0a 3c646963
743e0a09 3c6b6579 3e4c696e 636f6c6e 3c2f6b65 793e0a09 3c646963
743e0a09 093c6b65 793e444f 423c2f6b 65793e0a 09093c64 6174653e
31383039 2d30322d 31325430 393a3138 3a30305a 3c2f6461 74653e0a
09093c6b 65793e4e 616d653c 2f6b6579 3e0a0909 3c737472 696e673e
41627261 68616d20 4c696e63 6f6c6e3c 2f737472 696e673e 0a09093c
6b65793e 53636f72 65733c2f 6b65793e 0a09093c 61727261 793e0a09
09093c69 6e746567 65723e38 3c2f696e 74656765 723e0a09 09093c72
65616c3e 342e3930 30303030 30393533 36373433 31363c2f 7265616c
3e0a0909 093c696e 74656765 723e393c 2f696e74 65676572 3e0a0909
3c2f6172 7261793e 0a093c2f 64696374 3e0a093c 6b65793e 57617368
696e6774 6f6e3c2f 6b65793e 0a093c64 6963743e 0a09093c 6b65793e
444f423c 2f6b6579 3e0a0909 3c646174 653e3137 33322d30 322d3137
5430313a 33323a30 305a3c2f 64617465 3e0a0909 3c6b6579 3e4e616d
653c2f6b 65793e0a 09093c73 7472696e 673e4765 6f726765 20576173
68696e67 746f6e3c 2f737472 696e673e 0a09093c 6b65793e 53636f72
65733c2f 6b65793e 0a09093c 61727261 793e0a09 09093c69 6e746567
65723e36 3c2f696e 74656765 723e0a09 09093c72 65616c3e 342e3539
39393939 39303436 33323536 38343c2f 7265616c 3e0a0909 093c696e
74656765 723e363c 2f696e74 65676572 3e0a0909 3c2f6172 7261793e
0a093c2f 64696374 3e0a3c2f 64696374 3e0a3c2f 706c6973 743e0a>

now i want to do is that to display id in xml (nsstring) format ….

can any one please help me how to do that ….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T01:18:51+00:00Added an answer on May 25, 2026 at 1:18 am

    Add this to the end of your code snippet:

    NSString *plistString = [[NSString alloc] initWithData:plist encoding:NSUTF8StringEncoding];
    NSLog(@"the plist is: %@", plistString);
    
    2011-08-21 23:32:49.324 so7143762iPhone[5474:207] the plist is: <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>Lincoln</key>
        <dict>
            <key>DOB</key>
            <date>1809-02-12T09:18:00Z</date>
            <key>Name</key>
            <string>Abraham Lincoln</string>
            <key>Scores</key>
            <array>
                <integer>8</integer>
                <real>4.9000000953674316</real>
                <integer>9</integer>
            </array>
        </dict>
        <key>Washington</key>
        <dict>
            <key>DOB</key>
            <date>1732-02-17T01:32:00Z</date>
            <key>Name</key>
            <string>George Washington</string>
            <key>Scores</key>
            <array>
                <integer>6</integer>
                <real>4.5999999046325684</real>
                <integer>6</integer>
            </array>
        </dict>
    </dict>
    </plist>
    

    Also, in OS X I need to add nil to the end of the lists in the calls to arrayWithObjects. I assume it’s the same for iOS.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using preview 4 of ASP.NET MVC Code like: <%= Html.CheckBox( myCheckBox, Click Here, True,
I am using NSURLConnection to fetch XML data from the server. I am parsing
Using Java Reflection, is it possible to get the name of a local variable?
Using the classic code snippet: if (x & (x-1)) == 0 If the answer
Using Ivy with this Ant target: <target name=retrieve-jars> <ivy:retrieve pattern=WebContent/WEB-INF/lib/[artifact].[ext] /> </target> to fetch
Using online interfaces to a version control system is a nice way to have
Using PyObjC , you can use Python to write Cocoa applications for OS X.
Using ASP.NET MVC there are situations (such as form submission) that may require a
Using C# .NET 3.5 and WCF, I'm trying to write out some of the
Using TortoiseSVN against VisualSVN I delete a source file that I should not have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.