« Movie sketches | Main | Pardon the Interruption »

XML Parsing plugin for Maya

As it turns out, one of the most generally useful pieces of code I've written at work is an XML parser plugin. The studio uses XML for a variety of things: configuration files, asset storage and description, and also XML is stored in attributes on Maya nodes.

We had an XML parser library in C++ but nothing callable from MEL. The studio hadn't switched over to Python yet so there was no good solution. Before I got there, any functionality that needed to parse XML was either written in C++ (which means there are a number of tools written in C++ that should be MEL), or people just kind of did a rough grovel through the XML to extract what they needed and just hoped it worked.

Two or three weeks after I started (back in February or March of 2007), I spent a weekend wrapping the C++ XML library in a plugin. I took the design decision to make the interface look like the C++ methods and so I ended up with MEL commands like:


xmlGetNumChildren
xmlGetChild
xmlGetNumAttributes
xmlAppendAttribute
etc.

There are about twenty different commands. In hindsight this wasn't the right decision. While it's useful for people familiar with the XML parser, it's not very familiar to those native MEL speakers.

Even so, this has been very useful at work to a wide variety of people. So I decided I needed the same functionality at home, so I've been working on an XML parsing plugin in my spare time. I'm using Python some (both at work and at home) but haven't moved over completely so I think this will definitely get some use.

I found an XML parser by Frank Vanden Berghen to use and I've been writing a plugin in my spare time at home. It's given me a chance to correct the design flaw described above. Now there's just a handful of commands, one each for elements, attributes and data (plus a few utility functions for doing file I/O, etc). The commands support create, query and edit modes. A much better MEL-ish interface.

I'll be posting the plugin binaries plus the source and VS2005 project file in the next week or so. I've got a bit more work to do to finish it up along with some more testing.

Comments

Hi David,

Cannot wait for this plug-in, when will you be publishing it ?

Owain

David, this looks really useful, any chance you are closer to sharing the binairies? :D

Thanks for commenting Owain and William. I get so many spam comments, I didn't notice Owain's until William's came in. And I accidentally nuked William's comment in dealing with the several hundred spam comments that have come in between the two. William, I got your comment restored in spirit if not actuality.

I'll get the binaries put up by the end of this weekend. I've just finished up the test script for it and have a bug or two to fix. As soon as I figure out the licensing for the source, I'll be putting that up as well. I think probably one of the Creative Commons licenses, but I need to investigate a bit.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)