About loading XML in a page

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.