2009-04-28 29 views
2

MSXML6應該具有最好的安全性,性能,可靠性和W3C一致性(Using the right version of MSXML in Internet Explorer)。jQuery和MSXML

問題:

  1. 爲什麼不jQuery的使用MSXML6?
  2. jQuery使用MSXML3嗎? (我認爲答案是肯定的,請參閱下面的更新...)
  3. 我可以從IXMLDOMDocument實例獲取MSXML的版本嗎?如果是這樣,怎麼樣?

更新:

我做了基於越軌的回答一些研究:

jQuery創建IXMLHTTPRequest對象,這是首次用MSXML 2.0發佈,像這樣:

new ActiveXObject("Microsoft.XMLHTTP");

Microsoft.XMLHTTPProgID,它是only implemented in MSXML3 for legacy support並不推薦。如果我正確理解the reference這將創建一個版本2.x IXMLHTTPRequest對象,在那些版本是「kill-bitted」之前。現在我很確定這個ProgID創建了一個MSXML 3.0 IXMLHTTPRequest對象。這可以回答我的第二個問題。

下面是示例代碼演示如何創建IXMLHTTPRequest對象的推薦兩個版本:我已經測試XSLT性能MSXML3 VS MSXML6

new ActiveXObject("MSXML2.XMLHTTP.3.0"); // MSXML 3.0 ProgID... 
new ActiveXObject("MSXML2.XMLHTTP.6.0"); // MSXML 6.0 ProgID... 

。對於相當大的XML文件,MSXML6使用少於1/10的時間對MSXML3進行相同的轉換!

Rerences:

  1. jQuery: The Write Less, Do More, JavaScript Library
  2. IXMLHTTPRequest
  3. MSXML API History
  4. GUID and ProgID Information
  5. Using the right version of MSXML in Internet Explorer
  6. MSXML 3.0 GUIDs and ProgIDs
  7. MSXML 6.0 GUIDs and ProgIDs
  8. Why Version-Independent GUIDs and ProgIDs Were Removed

回答

7

jQuery不會。來源:

// Create the request object; Microsoft failed to properly 
// implement the XMLHttpRequest in IE7, so we use the ActiveXObject when it is available 
// This function can be overriden by calling jQuery.ajaxSetup 
xhr:function(){ 
    return window.ActiveXObject ? new ActiveXObject("Microsoft.XMLHTTP") : new XMLHttpRequest(); 
}, 

但它顯然無法在Firefox/Chrome瀏覽器/ Safari瀏覽器/歌劇等使用MSXML所以,如果你試圖在你的HTML中使用MSXML你的網站將只在IE瀏覽器。所以我不建議你這樣做。

jQuery只使用MSXML作爲備份來解決MS的XmlHttpRequest實現中的錯誤。

我不會說MSXML是最符合XMLHttpRequest標準的。 MSXML早在XMLHttpRequest出現之前就已存在,所以這是一個奇怪的比較。 http://www.w3.org/TR/XMLHttpRequest/

jQuery用於支持XML和XPath選擇器,但已被棄用。有針對jQuery和XML的插件http://plugins.jquery.com/search/node/xml+type:project_project

JSON通常比XML更受歡迎。 http://json.org

+0

IXMLHTTPRequest是MSXML – knut 2009-04-30 20:50:50