I have an XML file and I have to convert it into a property list file (plist). I tried the “plutil” command from the terminal, but it don’t works well. How can I convert?
Thanks a lot
I have an XML file and I have to convert it into a property
Share
I accomplished this by writing a formula in excel to create the text of the plist file for you. Its pretty easy.
1) (optional) In XCode, create a plist that has the formatting you want in the end. Save, and go to this in finder. Open it in textWrangler or text edit so that you can see what the tags are for each element in your plist.
For example, you should find something like:
2) I will assume:
– Your spreadsheet represents a description of the same 4 properties for many rows/Objects/Levels
– You have each array as a separate row in your spreadsheet
– The same properties are being described for every row in the same order.
– You will be able to access the items in the array by knowing which index they are stored at. ie, I would get the second Author by looking in the second array at index 2.
Your spreadsheet should look something like this:
So each of my objects will get its own key in my dictionary and each object is described by 3 Strings and an integer.
3) The Formula
On the right of the last column in my spreadsheet, I will write a formula that generates the xml code for that row:
Drag the lower-right corner of this cell down into all the other rows and they will automatically populate the information for each row.
Similarly, at the bottom of the spreadsheet, under all the rows you can use another formula to concatenate the rows. Say you had 300 rows:
Now copy this data into an text file, and add the last few tags and doctype information, which you can copy from above. save with the extension .plist and you’re good to go! Add the file back into your xcode project and load it like any other plist.