Solution to BUG in string and XML conversion under IE

Y2J
Release: 2017-05-09 10:33:04
Original
1664 people have browsed it

js defines an xml object, var data = "";

JQUERY can convert a string into an XML object, and then use the find() method to node the XML converted from the string operate.

But jQuery cannot parse XML under IE. What is parsed in IE is a text object.

Solution: Determine whether it is an IE browser. If so, re-create and load the xml object

   var xml;

    if ($.browser.msie) {// & parseInt($.browser.version) < 9
        alert("这是IE版本是");
        xml = new ActiveXObject("Microsoft.XMLDOM");
        xml.async = false;
        xml.loadXML(data);
        // xml = $(xml).children('nodes'); //这里的nodes为最顶级的节点
    } else {
        xml = data;
    }
    alert($(xml).find("DataRow").attr("Id"));
Copy after login

js Define an xml object, var data = "";

JQUERY A string can be converted into an XML object, and then the find() method can be used to perform node operations on the XML converted from the string.

But jQuery cannot parse XML under IE. What is parsed in IE is a text object.

Solution: Determine whether it is an IE browser. If so, recreate the loaded xml object

   var xml;
    if ($.browser.msie) {// & parseInt($.browser.version) < 9
        alert("这是IE版本是");
        xml = new ActiveXObject("Microsoft.XMLDOM");
        xml.async = false;
        xml.loadXML(data);
        // xml = $(xml).children('nodes'); //这里的nodes为最顶级的节点
    } else {
        xml = data;
    }
    alert($(xml).find("DataRow").attr("Id"));
Copy after login

[Related recommendations]

1. XML free video tutorial

2. Li Yanhui XHTML Video Tutorial

3. XML Technical Manual

The above is the detailed content of Solution to BUG in string and XML conversion under IE. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!