Quantcast
Channel: Internet Explorer Web Development forum
Viewing all articles
Browse latest Browse all 3527

Problem parsing XML with a hyphen in IE11

$
0
0

When using JavaScript to get the node value in an XML file, IE 11 and 10 drop all the characters in the string after a hyphen. 

An example of the XML:

<?xml version="1.0"?><ARCHIVE><YEARS>2015-2016</YEARS></ARCHIVE>

An example of the JavaScript:

var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { var m = xmlhttp.responseXML.documentElement.getElementsByTagName("YEARS"); for (var h=0; h < m.length; h++) { { try { txtYear = m[h].firstChild.nodeValue; } catch (er) { txtYear = " "; } } } }

xmlhttp.open("GET", url + "?nc=" + Math.random(), true);

xmlhttp.send();

IE 11 and 10 will return the value of txtYear as "2015", dropping "-2016" from the string. However, IE 9, Edge, Chrome and Firefox return the full value of "2015-2016". I have tried replace the hyphen in the XML file with the hex code for hyphen, but it still gets the same results. 

This use to work in IE 11, so I don't know if a recent patch has changed this or if I'm doing something wrong.

 

Viewing all articles
Browse latest Browse all 3527

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>