简体   繁体   中英

XML/XSLT in JavaScript

I've been looking into examples of using XML and XSLT in JavaScript and I don't understand the differences between the different options in IE:

  • Msxml2.DOMDocument.6.0
  • Msxml2.DOMDocument.3.0
  • Microsoft.XMLHTTP
  • Microsoft.XMLDom

So when using the approach:

var xml = new ActiveXObject("Xxxxxxx");

With xxxxxx being one of the above variations.

Which should I use? What is the difference between them?

Microsoft's COM based XML software package is called MSXML and exists in different versions that can co-exist on a Windows system. All currently supported Microsoft OS versions respectively latest supported service packs of Microsoft OS come with MSXML 3 and MSXML 6. The program ids you pass in to ActiveXObject in JScript are documented for MSXML 3 here: http://msdn.microsoft.com/en-us/library/ms766426%28v=vs.85%29 and for MSXML 6 here: http://msdn.microsoft.com/en-us/library/ms764622%28v=vs.85%29 . As you can see, somehow confusingly the program ids start with 'MSXML2' and the MSXML version is appended at the end so an MSXML 3.0 DOM document has the program id MSXML2.DOMDocument.3.0 and an MSXML 6.0 DOM document the program id Msxml2.DOMDocument.6.0 .

Program ids starting with Microsoft. are legacy program ids introduced with older MSXML versions, you shouldn't need them these days where MSXML 3 and MSXML 6 are part of the OS or latest service on any supported OS.

As for which version to choose of MSXML 3 or 6, that depends partly on what you want to do; the main difference between MSXML 3 and MSXML 6 is that MSXML 6 has a parser supporting validation against a schema or a schema set while MSXML 3 only supports DTD based validation. MSXML 6 by default also has some tighter security related settings you need to be aware of, see http://msdn.microsoft.com/en-us/library/ms754611%28v=vs.85%29 .

As your post also mentions XSLT, both MSXML 3 and 6 support XSLT and XPath 1.0 so in terms of standard compliance you can choose either of them, in terms of performance you might find that MSXML 6 performs better.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM