Solution to the BUG caused by string and XML conversion in IE

Source: Internet
Author: User
Js defines an xml object, vardata & quot; JQUERY can convert a string into an XML object, and then use find () method to perform node operations on the XML converted from this string. However, jQuery cannot parse XML in IE, and the text object is parsed in IE. Solution: Judge... js to define an xml object, var data = "";

JQUERY can convert a string into an XML object, and then use the find () method to perform node operations on the XML converted into this string.

However, jQuery cannot parse XML in IE, and the text object is parsed in IE.

Solution: Determine whether the web browser is an Internet Explorer. If yes, recreate and load the xml object.

Var xml; if ($. browser. msie) {// & parseInt ($. browser. version) <9 alert ("This is the IE version"); xml = new ActiveXObject ("Microsoft. XMLDOM "); xml. async = false; xml. loadXML (data); // xml = $ (xml ). children ('nodes '); // The nodes here is the top node} else {xml = data;} alert ($ (xml ). find ("DataRow "). attr ("Id "));

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

JQUERY can convert a string into an XML object, and then use the find () method to perform node operations on the XML converted into this string.

However, jQuery cannot parse XML in IE, and the text object is parsed in IE.

Solution: Determine whether the web browser is an Internet Explorer. If yes, recreate and load the xml object.

Var xml; if ($. browser. msie) {// & parseInt ($. browser. version) <9 alert ("This is the IE version"); xml = new ActiveXObject ("Microsoft. XMLDOM "); xml. async = false; xml. loadXML (data); // xml = $ (xml ). children ('nodes '); // The nodes here is the top node} else {xml = data;} alert ($ (xml ). find ("DataRow "). attr ("Id "));

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.