An XML Document to JavaScript Object Converter
By Alexander Hildyard
One of the ironies of Web technology is that many of the most interesting advances, such as the Document Object Model (DOM), Dynamic HTML, and style sheets, cannot be fully taken advantage of by Web developers unless they decide to target a specific browser vendor and version. Extensible Markup Language (XML), which is fast gaining currency as the industry standard for Web-based data transmission, is the latest in the parade of tempting technologies that demand patience from Web developers interested in client-side deployment and require creative thinking to apply in a diverse population of browsers.
At the time of writing, only Microsoft had shipped an XML parser with its browser (Internet Explorer 4.x), thereby limiting prospective Web-based XML clients to a proprietary rather than an open solution, despite the fact that XML itself represents an open standard. An extensive infrastructure of SGML tools exists at the server level as middleware with which to prime, filter, annotate, and parse XML. However, to date, the bottleneck in exploiting XML's open and generic standard remains at the level of the Web-based client, which has only a limited interface with which to interpret XML-encoded documents, and a slow one at that.
I have come up with an approach that brings some of the benefits of XML-based documents to non-XML browsers. My workaround is a server-side conversion of XML documents to JavaScript code; this code gets interpreted by the browser and results in a data structure roughly equivalent to the parse tree that would have been produced by an XML-enabled browser.