search
Twitter Rss Feeds
MicrosoftArticlesForumsGroups
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml/Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

Web ProgrammingArticlesForumsGroups
JavaScript
ASP
ASP.NET
Web Services

Non-MicrosoftArticlesForumsGroups
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

DatabasesArticlesForumsGroups
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsGroups
Microsoft Excel
Microsoft Word
Microsoft Powerpoint
Publisher
Money

Operating SystemsArticlesForumsGroups
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsGroups
Share Point
BizTalk
Site Server
Exhange Server
IIS
Transaction Server

Graphic DesignArticlesForumsGroups
Macromedia Flash
Adobe PhotoShop
Microsoft Expression

OtherArticlesForumsGroups
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Reviews
Search Engines
Resumes

 
How to automatically detect and install MSXML in a web page

By Peter A. Bromberg, Ph.D.

Peter Bromberg

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() section of a Javascript structured exception handling block, it is a simple 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:

<script language="JavaScript" >
var XMLDoc = "<?xml version=\"1.0\"?><STUFF>My Cool XML</STUFF>";
// Msxml2.DOMdocument.4.0
try{
var domDoc = new ActiveXObject("Msxml2.DOMdocument.4.0");
domDoc.async=false;
if (domDoc.loadXML(XMLDoc))
document.write("<INPUT TYPE=CHECKBOX DISABLED CHECKED>Msxml2.DOMdocument.4.0 </INPUT></BR>");
}
catch (e){
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\" codebase=\"msxml4.cab#version=8,00,7820,0\" type=\"application/x-oleobject\" STYLE=\"display: none\"></object>");
</Script>

 

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 EggheadCafe.com developer website. He can be reached at pbromberg@yahoo.com

 


Pete's Blog   |    Pete's Resume   |    Robbe's Blog   |    Robbe's Resume   |    Archive #2   |    Archive #3   |    Dotnetslackers   |    XmlPitStop   |    Advertise   |   Contact Us   |   Privacy   |   Copyright (c) 2000 - 2009 eggheadcafe.com  All rights reserved.