天天看点

MSXML2家族探秘

客户端程序编写免不了经常接触XMLHttpRequest对象。

微软的XHR实现的progid又是一串一串的。 烦人。抽一个中午时间,找了找资料,整理记录如下:

"Microsoft.XMLHTTP"

最早的XHR实现。微软官网上说这是MSXML 2.x系列版本的progid。

2.x 系列progid是不带版本号的。看起来简单清楚。

引用:

MSXML 2.6 was shipped with SQL Server 2000 and MDAC 2.6 and is provided in Windows or other service pack updates provided by Microsoft.

MSXML 2.6 installs in replace mode only.

"MSXML2.XMLHTTP"

MSXML 3.0 的progid,

"MSXML2.XMLHTTP.3.0"

也是MSXML 3.0 的,应该等价于MSXML2.XMLHTTP;这时,可能是感觉到那种不带版本号的progid,在升级后造成的兼容性问题,以后的更新版本的progid都可以带上版本好吗。

引用:

MSXML 3.0 is provided as a required component with a number of Microsoft products, such as Microsoft Visual Studio and Microsoft Office. It is also a system component for current versions of Microsoft Windows.

MSXML 3.0 SP2 or later installs in replace mode only. (Note: you do not need to run xmlinst.exe utility when updating to this version of MSXML 3.0)

"Msxml2.XMLHTTP.4.0"

此后的版本,都带上了版本号码,可能是为了应对程序员懒散的习惯(不喜欢带那个版本号),不提供以前那种无版本后缀的progid了。

引用:

MSXML 4.0 is a separate download that was released by Microsoft in October 2001. The latest or current service pack release of MSXML 4.0 is available through the Microsoft Web site. MSXML 4.0 must be installed separately and is not currently included with other Microsoft products.

MSXML 4.0 installs side-by-side with earlier versions of MSXML without affecting any existing functionality.

“Msxml2.XMLHTTP.5.0"

引用:

MSXML 5.0 for Microsoft Office Applications is only available with current versions of Microsoft Office.

MSXML 5.0 for Microsoft Office Applications installs side-by-side with earlier versions of MSXML without affecting any existing functionality.

"Msxml2.XMLHTTP.6.0"

引用:

MSXML 6.0 is a separate download that was released by Microsoft in November 2005. The latest or current service pack release of MSXML 6.0 is available through the Microsoft Web site. MSXML 6.0 must be installed separately. It is included with SQL Server 2005.

MSXML 6.0 installs side-by-side with earlier versions of MSXML without affecting any existing functionalit根据ie blog的建议,应该仅使用6.0和3.0。ie团队建议不要使用老的microsoft.xmlhttp,说这仅为兼容而保留,那个意思似乎是,如果你安装过了msxml 3.0,用microsoft.xmlhttp所产生的其实也是3.0版而不是2.6版的。 

但是4.0之后似乎抛弃了replace模式,而改用版本号了。并且MSXML2.XMLHTTP会始终对应3.0,而不会选取可用的最新版本。 

从各种小道新闻来看,6.0是继承3.0的,并由一个团队所开发。而4.0和5.0的开发并非主要针对浏览器的,属于旁支,存在一定的兼容问题,其中5.0是为office所开发的,甚至带有一些特性是后来的6.0所没有的(如xml数字加密)。 

此外在使用6.0时,还需要注意一个问题。就是ie7所带的native xmlhttprequest貌似是基于3.0而不是6.0的,而不同版本的xml节点是不能被互相插入和移动的。所以activex的6.0和native xhr不可互用。当然这一点我还没有验证测试过。

说到IE7的native XHR,我感觉到的与其他版本最大的区别是本体测试的时候它不能访问相对路径下的本地文件系统,有点麻烦。

另外,6.0貌似只有ie7支持吧,我在IE6上都没成功过。

IE7用户那么少,首先探测6.0,失败的机会很大啊。

继续阅读