When it comes to loading XML, I believe most people think of the XMLHttpRequest object, and below I give some other ways to load the XML file, if there are questions welcome, God, please detour ~
Let's start by saying how to create an XML document node, which is handy.
means that there may be more than one #document node in a page.
There are two kinds, ie can be used under
var New ActiveXObject (' Microsoft XMLDOM ';)
Note: about how to identify IE
Once the classic two classic very short way of IE identification, now can only distinguish IE8 and its following
if (!-[1,]) // IE8 and below if (!+ "\v1") // IE8 and below
There is also the ' MSIE ' method for searching the kernel prefix, and it is now impossible to discern the latest IE11.
if (Navigator.userAgent.indexOf (' MSIE ') >-1) // IE10 and below
Put two pictures, everybody knows, IE10 's navigator.useragent.
Then there's IE11, there's no ' MSIE '.
The way I use it is
if (Navigator.userAgent.indexOf (' Trident ') >-1) // all versions of IE
Don't know if anyone knows better ways to ask for help ~
Well, ie of the identification is finished, the idea of adjustment back, with the XmlDoc object, we directly call the Load method on it, the local problem is not ~
New ActiveXObject ("Microsoft.XMLDOM"); Xmldoc.load (' xxx.xml ');
ie after saying that Firefox, Firefox can also not be achieved through the XMLHttpRequest object
Also create a new XML document node
var xmldoc = Document.implementation.createDocument ("", "",null); //
Note: Now Firefox, Chrome, Safari,opera can create a document node like this
But the only thing underneath is Firefox.
Xmldoc.load (' Xxx.xml ');
The reason is that only Firefox has the Load method and no other browsers
Conclusion: Here is only the way to load the XML file, the format of the XML string becomes a document node is convenient (loading XML documents is actually convenient, just write some attention to the place), here does not mention ~
About loading XML in a page