Pragmatically Parsing Plists without Pruning Your Persimmons (if you know what I mean)

Enough euphemisms! I don’t even know what a plist is! Well you’re in the right place, cause I’m all out of euphemisms, and I’ve got plist pknowledge, paramount and plenty.

I was out programming an “HTML5, standards compliant web based tool” the other day, and I needed to be able to parse a .plist file (stands for Pancake List for those of you not sure what I’m talking about, it’s an XML based serialization format used by Apple). Unfortunately, JavaScript absolutely sucks at parsing XML (next to Flash + E4X), and I didn’t want to use a huge library. Next best thing? Rolling my own! It’s super easy, just call:

var jsonishObject = thegoldenmule.PlistParser.parse(xmlstring);

and it will return a beautiful json-ish object that’s much easier to deal with than XML.

I know what you’re thinking, “Enough chit-chat! Where can I download this wonderful parser?” Lucky for you I thought ahead and stuck it on github.

3 Comments

  1. Bolt

    jQuery rules at XML parsing….

    xml looks like:

    1
    2
    3

    js:

    $.ajax({
    type: “GET”,
    url: url,
    dataType: “text”,
    success: parse
    });

    function parse(data) {
    $(xml).find(“test list item”).each(function() {
    var item = $(this).text();
    console.log(“item: ” + item);
    });
    }

    Just sayin…

Comments are closed.