xmlparser xtra wrapper class

I recently wrote a JavaScript class to wrap the XmlParser Xtra for Authorware. Turns out I won’t be requiring it (atleast for now) and thought rather than abandon it I’d share it here. It’s pretty basic but I find it makes using the XmlParse.x32 in JavaScript a little more straightforward – allowing you to simply create an instance of the XmlParser. All the methods of the Xtra are then available as members of the instance. There is also one added method named destroy() which should be called before deleting an instance – it deletes the scripting Xtra object.

Here’s an example of creating a new instance:
var xml_file = "http://www.andrewlucking.com/feed/";
// create instance of XmlParser object
var my_xml = new XmlParser();
my_xml.ignoreWhitespace(true);
my_xml.parseFile(xml_file); // call parseFile method

I don’t consider it fully tested but am fairly confident it is solid so if you find any problems let me know. I find that the unique way the Xtra references the XML nodes takes a little while to get used to. Also I’ve noticed that calling parseMore() on a file that doesn’t exist (or that isn’t specified) will cause a fatal exception error. There’s a pretty foolproof parseMore() loop in the sample usage section of the class file. I think that’s about all.

Download link for the XmlParser.js.

Leave a Reply