how to export an XML with Plist in this schema?

Discussion in 'Mac Programming' started by saleh.hi.62, Jul 26, 2011.

  1. saleh.hi.62 macrumors member

    Joined:
    Jul 25, 2011
    #1
    Hello Guys,

    I have an Array of dictionaries
    Code:
    NSMutableArray* list = [NSMutableArray array];
    	[list addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"first value",@"text", @"number 1",@"value", nil]];
    	[list addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"second value",@"text", @"number 2",@"value", nil]];
    	[list addObject:[NSDictionary dictionaryWithObjectsAndKeys:@"third value",@"text", @"number 3",@"value", nil]];
    And with this command i made an XML file

    Code:
    	[list writeToFile:path atomically:YES];
    Code:
    <plist version="1.0">
    <array>
    	<dict>
    		<key>text1</key>
    		<string>first value</string>
    		<key>value</key>
    		<string>number 1</string>
    	</dict>
    	<dict>
    		<key>text2</key>
    		<string>second value</string>
    		<key>value</key>
    		<string>number 2</string>
    	</dict>
    	<dict>
    		<key>text3</key>
    		<string>third value</string>
    		<key>value</key>
    		<string>number 3</string>
    	</dict>
    </array>
    </plist>
    
    Here is my question!

    here is the way it represent the keys and values here,but how can i convert this tags :
    Code:
    <key>text3</key>
    <string>third value</string>
    to this form:
    Code:
    <text3>third value</text3>
    when i want to create them ?
     
  2. mfram macrumors 65816

    Joined:
    Jan 23, 2010
    Location:
    San Diego, CA USA
    #2
    You either create a routine to convert the XML created by writeToFile or perhaps you subclass NSMutableArray to override the writeToFile method.
     
  3. saleh.hi.62 thread starter macrumors member

    Joined:
    Jul 25, 2011
    #3
    is there any sample for that ?
     

Share This Page