Microsoft have provided a self-installing
CAB file for the MSXML4.0 parser, along with a sample <OBJECT> Tag
that illustrates how to automatically install this on the client .
By combining this code inside the catch()
matter to test to see if the component is already installed, and if not,
to write the required code dynamically which will cause the browser to
download and install the CAB.
Here's some sample code that tests for
the presence of MSXML4.0, and if it is not present, installs it transparently:
var XMLDoc = "<?xml version=\"1.0\"?><STUFF>My
var domDoc = new ActiveXObject("Msxml2.DOMdocument.4.0");
document.write("<INPUT TYPE=CHECKBOX DISABLED CHECKED>Msxml2.DOMdocument.4.0
document.write("<INPUT TYPE=CHECKBOX DISABLED>Msxml2.DOMdocument.4.0</INPUT>
| "+ e.description +"</BR>");
document.write("<object id=\"MSXML4\" classid=\"clsid:88d969c0-f192-11d4-a65f-0040963251e5\"
What we are doing here is creating a small
XML document string, and then we try to create the MSXML2.DomDocument.4.0
instance and load the XML document. If the component is there, we can
write out a checkbox (as shown) to indicate that it is installed.
If it is not installed, the method will
fail and our catch( ) block is executed. At the end we simply Response.write
out the object tag, making sure to set the codebase attribute to the exact
location of our CAB file, and Voila! our MSXML4 gets installed.
Peter Bromberg is an independent consultant specializing in distributed .NET solutionsa Senior Programmer
/ Analyst at in Orlando and a co-developer of the NullSkull.com
developer website. He can be reached at email@example.com