Updating Demos
peter | 19 January, 2010 | 10:40I’m continuing to update the demos with the copy of the library that works cross-browser (and will continue to do so). There was a slight delay in the motion capture demo due to the difference in how the browsers read xml files. We had been using:
xmlDoc = document.implementation.createDocument("","",null);
xmlDoc.async = false;
xmlDoc.load(xmlFile);
but Safari and Chrome don’t accept that. After a quick search (ignoring the pages that make it sound more complicated than it is and want to sell you code to take care of it) I found the answer to be quite simple.
xmlDoc = document.implementation.createDocument("","",null);
xmlDoc.async = false;
var xmlReq = new XMLHttpRequest();
xmlReq.open("GET", xmlFile, false);
xmlReq.send(null);
xmlDoc=xmlReq.responseXML;
It ends up as a few extra lines, but it works for all three. This was a problem with the code for that individual page, but it seems to be the kind of thing we can expect when trying to write complex code for multiple browsers.
I’ll be working on the particle systems demo next, as it also has a bit of code that is firefox only.

Hi, You could have also used JQuery to do the XML
AaronMT | 19 January, 2010 | 14:52Hi,
You could have also used JQuery to do the XML parsing.
- AaronMT
@-AaronMT: yeah, good point. i always use jQuery for XML parsing
Uli | 21 January, 2010 | 9:12@-AaronMT:
yeah, good point. i always use jQuery for XML parsing in my web apps. it’s the easiest way
but don’t forget the case sensitivity. this caused a bug in my first app using xml, which took my days to find. jQuery used innerHTML and converted the new tag-always to upper-case. traversing the xml-data i only used lower-case.
In the last line of the new code you assign
AndersH | 24 January, 2010 | 2:17In the last line of the new code you assign to xmlDoc, so the first two lines where you initialize xmlDoc seems redundant. And you should of course load the files async. Usage of XmlHttpRequest is pretty well documented.
Thanks. I just pulled the two old lines of
peter | 28 January, 2010 | 13:48Thanks. I just pulled the two old lines of code out. I am going to have to disagree about loading sync vs async though. What we had done in this demo was converted a motion capture file from .trc format into an xml file, from which we could then read which marker was where in what frame. So we needed the file to be loaded before we could display the data from it. By loading synchronously we guaranteed that the data would be there when we needed it, without having to add extraneous event listeners to call an extra function when the file was ready (which would delay the page from working until the data was ready anyway).
I will take a look at jQuery for further updates though.