I’ve an issue with IE9 with the following code:
var XMLDocument = data;
var erreurs = new Array();
var test = data.lastChild.lastChild.childNodes;
for(var i=0; i<test.length; i++)
{
//var testx = test[i].textContent;
//alert("Test"+i+" = "+testx);
var testx = getText(test[i]);
alert(testx);
erreurs[i] = testx;
}
function getText(el) {
return el.textContent || el.innerText || el.nodeValue || '';
}
In FF, Opera and Safari, this code works fine.
In IE, it gives me:
Test0 = undefined
Test1 = undefined
My XML:
<error>
<missing>1</missing>
<missing>2</missing>
<missing>a</missing>
</error>
I just want to return the values of the nodes “missing”.
Thank you very much for your help.
I found the solution on this site:
http://www.chezneg.fr/leblog/chezneg-leblog.php?id_art=125
Seemingly, IE and FF interpreter don’t read the XML Document in the same way.
For FF, error tag is located here: data.lastChild.lastChild.childNodes
For IE, error tag is located here: data.lastChild.lastChild.lastChild.lastChild.childNodes
(dixit the debugger)
Therefore, it’s a better idea to locate the error tag via the following code: data.getElementsByTagName(‘error’);
Many thanks anyway to Esailija for the help !