the labs @ laan thoughts and other ramblings

Posted
19 December 2008 @ 2pm

Tagged
Uncategorized

Parsing Apple’s plist xml format in AS3

This is just a random thing I needed to make so I thought I would post it.

This class lets you parse the plist xml format into a more as3 style xml object. The plist format is not heirarchical for its key/value pairs, it has them in the same level. This will just make a more heirarchical representation. It’s not perfect and only supports array,dict,string, and integer, but it’s very easy to add other things.

here is a usage:

 
var plist : XML = 
	<plist version="1.0">
	    <array>
	        <dict>
	            <key>title</key>
	            <string>Angry Cat</string>
	            <key>fileName</key>
	            <string>cat_angry1.caf</string>
	            <key>fileArray</key>
	            <array>
	                <dict>
	                    <key>fileName</key>
	                    <string>cat_angry1.caf</string>
	                </dict>
	            </array>
	            <key>icon</key>
	            <string>icon1.png</string>
	            <key>buttonIndex</key>
	            <integer>0</integer>
	        </dict>
	    </array>
	</plist>;
 
   var parsed : XML = PlistParser.parsePlist( plist );
   trace( parsed.item.title );

Download the file: PlistParser.as


3 Comments

I like to see this sort of thing. Thanks for sharing.

  Posted by kortina - 19 December 2008 @ 11pm

this is really useful — thanks

  Posted by snackfeed - 13 January 2009 @ 5pm

Same here. Now one of the trusted names in the digital age has a parse-able plist xml format in AS3. Good for us!

  Posted by Maiden Name - 17 September 2009 @ 9am

Leave a Comment