March 02, 2006

More on XML with JavaScript: JSXML does in a pinch

About two months ago I posted a note about browser-side XML parsing with JavaScript. At the time I didn't find anything directly useful and just created a standard stupid-simple one myself. As you'd expect the fragility of such a system made itself a nuisance -- it worked fine for a while, and had the benefit of being 100% on-target for my needs, but when the incoming message changed a bit (requiring a CDATA section instead of an attribute) the solution didn't scale so well.

So with irrational optimism I went back to google and found the same crappy stuff. (Why does everyone want to redo the same contrived machinations with DOM?) But in a dojo post I found a reference to JSXML, a cross-browser library that includes REXML, using regular expressions to parse a document. While it hadn't been updated ina while it touted speed as a feature and the code was fairly small.

Plugging it in was a piece of cake and amounted to building my useful object from the tree of parsed objects instead of as-you-go. It may be less efficient<a href=#note1">[1]</a>, but it's much easier on me.

[1] While the REXML boasts about being super-speedy, it also hasn't been updated in four years. Browsers may have made strides in XML parsing since then.

Next: Riding in the MS 150
Previous: I am Spider-Man!