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