Daniel Crvelin

Navigation

Skip navigation.

Search

Site navigation

Email conversation

FromDaniel Crvelin
ToMe
SubjectActiveXObject containing multiple XML Files
Date9 August 2005 14:53
Hi Mark

Hope you can give me some support regarding following problem. I have a site
with multiple elements (dropdowns) who's content are based on
xml files. Is there any way to load those xml files in one single
ActiveXObject instead of initiate one ActiveXObject for each xml file (which
i'm doing for the time beeing, like shown below)? Can an ActiveXObject be
used like an art of Array?

By the way, it only has to run for Windows IE (6).

----------

gXmlDoc01 = new ActiveXObject('Microsoft.XMLDOM');
gXmlDoc01.async = false;
gXmlDoc01.load('fileOne_.xml');

gXmlDoc02 = new ActiveXObject('Microsoft.XMLDOM');
gXmlDoc02.async = false;
gXmlDoc02.load('fileTwo_.xml');

gXmlDoc03 = new ActiveXObject('Microsoft.XMLDOM');
gXmlDoc03.async = false;
gXmlDoc03.load('fileThree_.xml');


Many Thanks in Advance.
Regards Daniel
FromMe
ToDaniel Crvelin
SubjectRe: ActiveXObject containing multiple XML Files
Date9 August 2005 15:29
Daniel,

> By the way, it only has to run for Windows IE (6).

Yeah, because your company will never ever ever ever switch to another
browser. Well, they won't if you keep programming like that anyway ...

Even for private use it is a very bad idea to tie yourselves to a piece of
garbage.

> Is there any way to load those xml files in one single
> ActiveXObject instead of initiate one ActiveXObject

replace ActiveXObject with XMLHttpRequest. and the answer is yes.

The .open method resets the XMLHttpRequest object to its pre-loaded state.
Whenever one loads, keep a copy of its responseXML, and store that in a
custom array, then use the open method to reset the request object, ready to
make the next request.

see the Web Applications 1.0 Working Draft for details of how to use it:
http://www.whatwg.org/specs/web-apps/current-work/#xmlhttprequest

IE is largely the same, but you must use the ActiveXObject call instead of
the XMLHttpRequest constructor. Of course, you could also use an if
statement to check for window.XMLHttpRequest, then use ActiveX if
window.XMLHttpRequest is not available:

if( window.XMLHttpRequest ) {
  var gXmlDoc = new XMLHttpRequest();
} else if( window.ActiveXObject ) {
  var gXmlDoc = new ActiveXObject('Microsoft.XMLDOM');
} else { return; }

This way it will work in IE 6, and _when_ your company chooses to switch to
a better browser, it will keep working in the better browser as well.


Mark 'Tarquin' Wilton-Jones - author of http://www.howtocreate.co.uk/
FromDaniel Crvelin
ToMe
SubjectRe: ActiveXObject containing multiple XML Files
Date9 August 2005 16:24
Hi Mark

Thank you for your indication. I'll try it out.

Sounds like you're not a big fan of IE  :-)  Well, regarding that i agree with
you. But unfortunately the point of no return is transgressed. Already long
before my time.

Regards, Daniel
This site was created by Mark "Tarquin" Wilton-Jones.
Don't click this link unless you want to be banned from our site.