Jump to content

Ie9- Vs Ie9: Childnodes


tinfanide
 Share

Recommended Posts

JS:

function parseXML(method,xml,async){if(window.XMLHttpRequest){  xmlhttp = new XMLHttpRequest();  xmlhttp.open(method,xml,async);  xmlhttp.send();  }else {  xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") ;  xmlhttp.async=async;  xmlhttp.load(xml);  }xmlDoc = xmlhttp.responseXML;}parseXML("GET","answers.xml",false);alert(xmlDoc.getElementsByTagName("ans")[0].childNodes[0].nodeValue[0]);

The XML:

<?xml version="1.0" encoding="utf-8"?><database>  <ans>a</ans>   <ans>b</ans></database>

I want to ask if there is a IE7, 8, 9 solution inXML parsingI mean for childNodes As in IE9I get the result of "a" which is right But in IE7, 8The result is "undefined" in the IE9 Developer Tool

Link to comment
Share on other sites

I want to ask if there is a IE7, 8, 9 solution
The cross-browser way to use childNodes is to eliminate all empty whitespace nodes from the XML file. That way, IE9 takes the first node, which is the element, and IE9- take the first non-empty node, which happens to also be the first node according to IE9 and other browsers.
Link to comment
Share on other sites

If you have that [0] at the end then it's not going to work (or it might just return the first letter of the string) since nodeValue isn't an array. The expression does "mean" that, it just returns that data from the data tree.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...