ANSWERED: removing the header info from the XML file solved the issue. IE is great!
The following code works in Firefox and Chrome, not in IE.
I get the error
SCRIPT5007: Unable to get value of the property 'childNodes': object is null or undefined.
line 106, character 3`
Line 106 is the first line inside the sort function, the one that begins 'var aCat = a.getElementsByTagName'....
None of the nodes being sorted are empty, although within the same in the xml file, there are some blank nodes (ie im sorting on , none of which are empty, but some people don't have phone number, or beeper numbers, etc. so some of those are empty)
When I tried putting the sort in a try-catch block IE just didn't read any of the nodes, they all threw an exception. (again, Chrome and Firefox worked with the try-catch block)
I'm stumped, any ideas?
function populateSection(listType, tableID ) {
if (window.XMLHttpRequest) {/*code for IE7+, Firefox, Chrome, Opera, Safari*/ xmlhttp=new XMLHttpRequest(); }
else {/* code for IE6, IE5*/ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); }
var table = tableID;
var list = listType;
xmlhttp.open("GET",'contactlist.xml',false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
var xmlGet = xmlDoc.getElementsByTagName("PERSON");
var x = Array.prototype.slice.call(xmlGet,0);
x.sort(function(a,b) {
var aCat = a.getElementsByTagName("LASTNAME")[0].childNodes[0].nodeValue;
var bCat = b.getElementsByTagName("LASTNAME")[0].childNodes[0].nodeValue;
if (aCat > bCat) return 1;
if (aCat < bCat) return -1;
return 0;
});
//then cycle through the array, adding table rows for each node
...}
EDIT: Here's a portion of the xml file:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<CONTACTLIST xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<PERSON>
<LASTNAME>ALLEN</LASTNAME>
<FIRSTNAME>Korrie</FIRSTNAME>
<EMAIL>redacted@evms.edu</EMAIL>
<PHONE>123456</PHONE>
<LIST>main</LIST>
</PERSON>
<PERSON>
<LASTNAME>BUESCHER</LASTNAME>
<FIRSTNAME>Chris</FIRSTNAME>
<EMAIL>redacted</EMAIL>
<LIST>main</LIST>
</PERSON>
<PERSON>
<LASTNAME>BUESCHER</LASTNAME>
<FIRSTNAME>Steve</FIRSTNAME>
<EMAIL>redacted@evms.edu</EMAIL>
<PHONE>123456</PHONE>
<LIST>main</LIST>
<LABOTHER>123456</LABOTHER>
<BEEPER>123456</BEEPER>
</PERSON>
<PERSON>
<LASTNAME>CHARTERS</LASTNAME>
<FIRSTNAME>Michelle</FIRSTNAME>
<EMAIL>redacted@evms.edu</EMAIL>
<PHONE>123456</PHONE>
<LIST>main</LIST>
</PERSON>