Home  >  Article  >  Backend Development  >  Solution to BUG in string and XML conversion under IE

Solution to BUG in string and XML conversion under IE

Y2J
Y2JOriginal
2017-05-09 10:33:041615browse

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"));

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"));

[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!

Statement:
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