LIS 525 - Using XML data with XMLHTTPRequest to populate an HTML table


More recent browsers have introduced into JavaScript a method allowing access to the contents of an external text or XML file. In Internet Explorer through version 6, this is implemented as an ActiveX object Microsoft.XMLHTTP. In other browsers, it is simply a built-in object type XMLHTTPRequest of the window.

Because of security concerns, there are a couple of limitations: the text or XML file must be in the same location as the HTML file containing the JavaScript; and, if the location is not a local device, the server must have an accepted certificate. In addition, for automatically analyzing the XML structure, Internet Explorer insists that the MIME type be correct; otherwise, the structure is left empty, though the raw text can still be accessed.

Using this method is nowhere near as simple as the table binding that is available in Internet Explorer and errors can result in pages that hang or display nothing or only partial data, but it is potentially far more versatile and is workable in all common graphical browsers.

As a simple illustration, the following replicates the bound table shown in 525xbh.htm. To keep the scripting fairly simple, the XML file was edited to ensure that each term had a note that consisted of at least one character.

The Table

For More Information


Last updated April 20, 2007.
This page maintained by Prof. Tim Craven
E-mail (text/plain only):
Faculty of Information and Media Studies
University of Western Ontario,
London, Ontario
Canada, N6A 5B7